【发布时间】:2017-07-05 09:10:49
【问题描述】:
我使用不同的工具(sentinelsat et sen2cor)构建了一个 docker 容器:
#Modified Ubuntu docker image, adding some dependencies
#Starting image
FROM ubuntu
#Install of Anaconda2-4.2.0 (from docker anaconda : https://github.com/ContinuumIO/docker-images/tree/master/anaconda)
RUN apt-get update --fix-missing && apt-get install -y wget bzip2 ca-certificates \
libglib2.0-0 libxext6 libsm6 libxrender1 \
git mercurial subversion
RUN echo 'export PATH=/opt/conda/bin:$PATH' > /etc/profile.d/conda.sh && \
wget --quiet https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh -O ~/anaconda.sh && \
/bin/bash ~/anaconda.sh -b -p /opt/conda && \
rm ~/anaconda.sh
RUN apt-get install -y curl grep sed dpkg && \
TINI_VERSION=`curl https://github.com/krallin/tini/releases/latest | grep -o "/v.*\"" | sed 's:^..\(.*\).$:\1:'` && \
curl -L "https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini_${TINI_VERSION}.deb" > tini.deb && \
dpkg -i tini.deb && \
rm tini.deb && \
apt-get clean
ENV PATH /opt/conda/bin:$PATH
RUN conda update conda -y
RUN apt-get install -y zip
#Sentinelsat install (https://github.com/ibamacsr/sentinelsat)
RUN pip install sentinelsat
#Sen2cor install (from lvhengani : https://github.com/lvhengani/sen2cor_docker)
ENV SEN2COR_VERSION='2.3.1'
RUN wget http://step.esa.int/thirdparties/sen2cor/${SEN2COR_VERSION}/sen2cor-${SEN2COR_VERSION}.tar.gz && \
tar -xvzf sen2cor-${SEN2COR_VERSION}.tar.gz && \
cd sen2cor-${SEN2COR_VERSION} && \
/bin/echo -e "y\ny\ny\n" | python setup.py install
RUN rm sen2cor-${SEN2COR_VERSION}.tar.gz && rm -r /sen2cor-${SEN2COR_VERSION}
#Path environment variables for sen2cor to allow use of sen2cor in command lines, useless with webpage
ENV SEN2COR_HOME=/root/sen2cor
ENV SEN2COR_BIN=/opt/conda/lib/python2.7/site-packages/sen2cor-${SEN2COR_VERSION}-py2.7.egg/sen2cor
ENV GDAL_DATA=/opt/conda/lib/python2.7/site-packages/sen2cor-${SEN2COR_VERSION}-py2.7.egg/sen2cor/cfg/gdal_data
#Install of Apache2 , PHP7 and MySQL
RUN DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get upgrade -y && \
apt-get install -y --no-install-recommends iproute2 apache2 php7.0 libapache2-mod-php7.0 \
php7.0-mysql php7.0-sqlite php7.0-bcmath php7.0-curl ca-certificates && \
apt-get autoremove -y && \
rm -rf /var/lib/apt/lists/* && \
echo "ServerName $(ip route get 8.8.8.8 | awk '{print $NF; exit}')" >> /etc/apache2/apache2.conf && \
a2enmod php7.0 && \
a2enmod rewrite && \
a2enmod env && \
sed -i "s/short_open_tag = Off/short_open_tag = On/" /etc/php/7.0/apache2/php.ini
RUN ln -sf /dev/stdout /var/log/apache2/access.log \
&& ln -sf /dev/stderr /var/log/apache2/error.log
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
#Allow PHP to use sen2cor, repositories where sen2cor has to write logs
RUN chown www-data:www-data /opt/conda/lib/python2.7/site-packages/sen2cor-2.3.1-py2.7.egg/ && \
chown www-data:www-data /root/ && \
chown www-data:www-data /root/sen2cor/
# Adding modified configuration files to allow Apache to access env variables from Sen2cor
ADD ./conf_files/environment /etc/
ADD ./conf_files/envvars /etc/apache2/
#Move php files to apache repo
COPY ./web_page /var/www/html/
RUN rm /var/www/html/index.html
RUN chown www-data:www-data /var/www/html/ && \
mkdir /var/www/html/downloads && \
chown www-data:www-data /var/www/html/downloads/
#CMD /usr/sbin/apache2ctl -D FOREGROUND
我遇到的问题是,当我在 Windows 上使用具有此配置的 docker 工具箱在笔记本电脑上运行时:
$ docker version
Client:
Version: 17.05.0-ce
API version: 1.29
Go version: go1.7.5
Git commit: 89658be
Built: Fri May 5 15:36:11 2017
OS/Arch: windows/amd64
Server:
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:51:55 2017
OS/Arch: linux/amd64
Experimental: false
容器完美地执行 PHP 要求的操作。 我正在尝试在具有此配置的虚拟机上运行此容器:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"
还有这个 docker 配置:
Client:
Version: 17.06.0-ce
API version: 1.30
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:19:16 2017
OS/Arch: linux/amd64
Server:
Version: 17.06.0-ce
API version: 1.30 (minimum version 1.12)
Go version: go1.8.3
Git commit: 02c1d87
Built: Fri Jun 23 21:17:13 2017
OS/Arch: linux/amd64
Experimental: false
当容器尝试访问 repo /root/sen2cor/ 以创建日志时,我遇到了权限问题。 repo /root/ 和 /root/sen2cor 都具有 PHP 可写所需的权限。
我尝试在两者上都使用chmod 777,但不能解决问题。
我还在 Windows、17.04 和 17.05 上尝试了不同版本的 Docker,容器在这两个版本上都能完美运行。
我尝试在虚拟机上使用sudo docker run ..,我还尝试将用户添加到docker组,然后运行docker run ..,我也遇到了同样的权限问题。
我什至尝试在我的 Windows 设置上构建映像(经过测试并且可以正常工作),然后将其上传到 dockerhub 并从虚拟机中拉取以运行它,但它仍然存在权限问题。
有什么想法吗?
【问题讨论】:
标签: php docker dockerfile boot2docker docker-toolbox