0

I build a docker container using differents tools (sentinelsat et sen2cor) :

    #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

The issue I have is that when running on my laptop on Windows using docker toolbox with this configuration :

    $ 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

The container executes the actions asked by the PHP perfectly. I am trying to run this container on a virtual machine with this configuration :

    DISTRIB_ID=Ubuntu
    DISTRIB_RELEASE=14.04
    DISTRIB_CODENAME=trusty
    DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"

and this docker configuration :

    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

And I have permissions issue when the container try to access the repo /root/sen2cor/ to create a log. The repo /root/ and /root/sen2cor both have the permissions needed to be writable by the PHP.

I tried using chmod 777 on both, it doesn't solve the issue.

I also tried differents versions of Docker on Windows, the 17.04, and the 17.05, and the container works perfectly on both.

I have tried using sudo docker run .. on the virtual machine and I also tried adding an user to the docker group, and then runnning docker run .. and I have the same permission issue.

I even tried building the image on my windows setup (tested it and it worked) then upload it on dockerhub and pull it from the virtual machine to run it, but it still had the permissions issues.

Any ideas ?

4

1 回答 1

0

找到了解决方案,我只需要将 Sen2cor 安装到另一个存储库。我不知道为什么,但是 sen2cor 默认安装在 /root/sen2cor 中,所以我不得不替换/bin/echo -e "y\ny\ny\n" | python setup.py install“安装 sen2cor”上的命令/bin/echo -e "y\nn\n/var/www/html/sen2cor\ny\ny\n" | python setup.py install,这样 Apache 就可以访问它并运行它。

我仍然不知道为什么容器在一个主机上运行而不是在另一个主机上运行,​​如果它来自 Docker,这有点问题。

于 2017-07-10T07:10:28.063 回答