为什么环境变量没有在我的docker容器中设置?

时间:2016-09-13 19:04:38

标签: docker docker-compose

我的docker-compose.yml中有以下内容:

  php:
    build:
      args:
        http_proxy:
        https_proxy:
        no_proxy:
      context: ./vm-images/php
    environment:
      http_proxy:
      https_proxy:
      no_proxy:
      CURRENT_ENVIRONMENT: DOCKER
    container_name: php
    ports:
      - "9000:9000"
    depends_on:
      - mysql
    links:
      - mysql:mysql
    logging:
      driver: "json-file"
    volumes:
      - /var/www/:/var/www/

我的DOCKERFILE具有以下内容:

FROM ubuntu:latest

RUN locale-gen en_US.UTF-8 && \
    export LANG=en_US.UTF-8 && \
    export LC_ALL=en_US.UTF-8

RUN apt-get update && \
    apt-get install -y --reinstall ca-certificates

RUN apt-get update \
    && apt-get install -y --allow-unauthenticated --no-install-recommends \
    software-properties-common python-software-properties

RUN add-apt-repository ppa:ondrej/php

RUN apt-get update \
    && apt-get install -y --allow-unauthenticated --no-install-recommends \
    git-core \
    libjpeg-progs \
    mysql-client \
    optipng \
    php5.6 \
    php5.6-curl \
    php5.6-intl \
    php5.6-fpm \
    php5.6-gd \
    php5.6-mcrypt \
    php5.6-mysqli \
    php5.6-pdo \
    php5.6-xdebug \
    php5.6-xml \
    php5.6-zip

RUN rm -r /var/lib/apt/lists/*
RUN rm -r /var/cache/apt/*

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
    php -r "if (hash_file('SHA384', 'composer-setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" && \
    php composer-setup.php --install-dir=/usr/local/bin --filename=composer && \
    php -r "unlink('composer-setup.php');"

RUN mkdir -p /run/php && chown www-data:www-data /run/php 

COPY files/etc/php/fpm/php-fpm.conf /etc/php/5.6/fpm/php-fpm.conf
COPY files/etc/php/fpm/pool.d/www.conf /etc/php/5.6/fpm/pool.d/www.conf
COPY files/etc/php/fpm/php.ini /etc/php/5.6/fpm/php.ini
COPY files/etc/php/cli/php.ini /etc/php/5.6/cli/php.ini
COPY files/etc/php/mods-available/xdebug.ini /etc/php/5.6/mods-available/xdebug.ini

RUN phpenmod curl intl gd mcrypt mysqli pdo xdebug xml zip

CMD ["php-fpm5.6", "--nodaemonize", "--fpm-config", "/etc/php/5.6/fpm/php-fpm.conf"]

当我运行docker-compose --verbose up -d时,我注意到我的php容器没有传入env vars。我已经验证了那些env变量是在我的主机上设置的,并且它们会被传递给我所有其他容器而不会失败。有人有什么想法吗?

编辑:奇怪的是,我还注意到/proc/$PID/environ(其中$ PID是主机上运行docker inspect --format "{{.State.Pid}}" php获得的php容器的PID是空的。

0 个答案:

没有答案