Docker - Create new files as www-data and not root - docker

I have a basic docker container which I build using docker-compose (version 3) to bring up a basic LAMP stack.
The issue I am having is that files created inside the docker container are always owned by root, so I am unable to edit them locally.
I have tried setting the container www-data user to have the same uid as my local user, which works, but new files are still created by root.
How do I create file in the container that I can edit locally?
My compose file;
version: "3"
services:
webserver:
build:
context: ./docker/containers/webserver
container_name: 'apache7.1-webserver'
restart: 'always'
ports:
- "80:80"
- "443:443"
links:
- mysql
volumes:
- ${DOCUMENT_ROOT}:/var/www/html
- ${PHP_INI}:/usr/local/etc/php/php.ini
- ${VHOSTS_DIR}:/etc/apache2/sites-enabled
- ${APACHE_LOG_DIR}:/var/log/apache2
mysql:
build: ./docker/containers/mysql
container_name: 'apache7.1-mysql'
restart: 'always'
ports:
- "3306:3306"
volumes:
- ${MYSQL_DATA_DIR}:/var/lib/mysql
- ${MYSQL_LOG_DIR}:/var/log/mysql
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_DATABASE: ${MYSQL_DATABASE}
MYSQL_USER: ${MYSQL_USER}
MYSQL_PASSWORD: ${MYSQL_PASSWORD}
redis:
container_name: 'apache7.1-redis'
image: redis:latest
ports:
- "6379:6379"
My webserver Dockerfile;
FROM php:7.1-apache
# Get any build argument overrides
ARG APP_UID
ARG APP_GID
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN apt-get clean -y \
&& apt-get update -y \
&& apt-get install -y \
g++ \
locales \
libxml2-dev \
php-soap \
zlib1g-dev \
libicu-dev \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng12-dev \
libmcrypt-dev \
libpng12-dev \
libcurl4-openssl-dev \
libxml2-dev \
nano \
&& apt-get clean -y
RUN docker-php-ext-install mysqli mbstring zip intl mcrypt curl json
RUN docker-php-ext-install iconv xml xmlrpc
RUN docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
# Add any required locales here and restart php-fpm, note that some locales do not include currencies such as EURO, if
# this is the case then they will need to be generated in addition to main locale
RUN sed -i -e 's/# en_GB.UTF-8 UTF-8/en_GB.UTF-8 UTF-8/' /etc/locale.gen \
&& sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen \
&& sed -i -e 's/# pt_BR.UTF-8 UTF-8/pt_BR.UTF-8 UTF-8/' /etc/locale.gen \
&& sed -i -e 's/# de_AT.UTF-8 UTF-8/de_AT.UTF-8 UTF-8/' /etc/locale.gen \
&& sed -i -e 's/# de_AT#euro ISO-8859-15/de_AT#euro ISO-8859-15/' /etc/locale.gen \
&& sed -i -e 's/# de_DE.UTF-8 UTF-8/de_DE.UTF-8 UTF-8/' /etc/locale.gen \
&& sed -i -e 's/# fr_FR.UTF-8 UTF-8/fr_FR.UTF-8 UTF-8/' /etc/locale.gen \
&& dpkg-reconfigure --frontend=noninteractive locales \
&& kill -USR2 1
RUN pecl install redis-3.1.2 \
&& pecl install xdebug-2.5.0 \
&& docker-php-ext-enable redis xdebug
# Enable apache modules
RUN a2enmod rewrite headers
# Change www-data user to match the host system UID and GID and chown www directory
RUN usermod --non-unique --uid 1000 www-data \
&& groupmod --non-unique --gid 1000 www-data \
&& chown -R www-data:www-data /var/www

You can set the user with the USER directive https://docs.docker.com/engine/reference/builder/#user.
So you would need to for example add USER 1000 or USER www-data in the Dockerfile.

With the combination of USER instruction and chown command inside the Dockerfile, you could change the PHP user and the owner of the root directory to www-data:
FROM php:8.1.1-fpm
.
.
.
RUN chown -R www-data:www-data /var/www
USER www-data
Not that the USER instruction is at the end of the Dockerfile (or before CMD instruction, if it exists), otherwise you might get permission denied error for the next instructions.

Related

Docker chown folder on volume binded with magento

I am actually blocked because when I add this command in my Dockerfile
"RUN ln -s /etc/nginx/sites-available/local.magento /etc/nginx/sites-enabled" to activate my virtual host, I have always the same error
"nginx: [emerg] open() "/var/www/html/magento2/site/nginx.conf.sample" failed (13: Permission denied) in /etc/nginx/sites-enabled/local.magento:10"
Although I have made add this command "mkdir -p /var/www/html;
chmod 777 -R /var/www/html;
chown rootless:rootless /var/www/html; ", I have read that we cannot make a chown for an other user on a folder already binded by a volume. I have read every posts on that and I tried every methods without succeed. So I guess I must not use a correct method elsewhere.
Could you please tell me what's wrong with my dockerfile?
RUN apt-get -y update
##creation du user qui sera owner des dossiers
#
RUN groupadd -g 1000 rootless \
&& useradd -g 1000 -u 1000 -d /var/www -s /bin/bash rootless
#
#
#
#installation de nginx
RUN apt-get update \
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
default-mysql-client \
nginx
#
#
#
# installation de php
RUN apt-get clean && apt-get update
RUN apt-get install -y ca-certificates apt-transport-https software-properties-common wget curl lsb-release
RUN curl -sSL https://packages.sury.org/php/README.txt | bash -x
RUN apt-get update
RUN wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
RUN echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list
RUN apt-get install -y php8.1-fpm php8.1-cli \
php8.1-curl \
php8.1-bcmath \
php8.1-intl \
php8.1-mbstring \
php8.1-xmlrpc \
php8.1-mcrypt \
php8.1-mysql \
php8.1-gd \
php8.1-xml \
php8.1-cli \
php8.1-ctype \
php8.1-dom \
php8.1-fileinfo \
php8.1-iconv \
php8.1-simplexml \
php8.1-soap \
php8.1-sockets \
php8.1-tokenizer \
php8.1-xmlwriter \
php8.1-xsl \
php8.1-zip
#
RUN mkdir -p /var/www/html/magento
COPY ./conf/nginx/local.magento /etc/nginx/sites-available/local.magento
#RUN ln -s /etc/nginx/sites-available/local.magento /etc/nginx/sites-enabled
RUN service php8.1-fpm stop;
RUN service php8.1-fpm start;
RUN service nginx restart;
#installation de composer
RUN curl -O https://getcomposer.org/download/2.2.17/composer.phar | php
RUN mv composer.phar /usr/local/bin/composer && chmod +x /usr/local/bin/composer
#
#
#
##MAJ des droits pour rootless
RUN set -eux; \
mkdir -p /etc/php; \
chmod 777 -R /etc/php; \
chown rootless:rootless /etc/php; \
mkdir -p /etc/nginx; \
chmod 777 -R /etc/nginx; \
chown rootless:rootless /etc/nginx; \
mkdir -p /var/pid; \
chmod 777 -R /var/pid/; \
chown rootless:rootless /var/pid; \
mkdir -p /var/run; \
chmod 777 -R /var/run/; \
chown rootless:rootless /var/run; \
mkdir -p /var/lock; \
mkdir -p /var/lock/opcache; \
chmod 777 -R /var/lock/; \
chown rootless:rootless /var/lock; \
mkdir -p /var/log; \
chmod 777 -R -R /var/log; \
chown rootless:rootless /var/log; \
mkdir -p /var/cache; \
mkdir -p /var/cache/composer; \
mkdir -p /var/cache/opcache; \
chmod 777 -R /var/cache; \
chown rootless:rootless /var/cache; \
mkdir -p /var/lib; \
mkdir -p /var/lib/mysql; \
mkdir -p /var/lib/nginx; \
mkdir -p /var/lib/nginx/body; \
chmod 777 -R /var/lib; \
chown rootless:rootless /var/lib; \
mkdir -p /var/www/html; \
chmod 777 -R /var/www/html; \
chown rootless:rootless /var/www/html; \
mkdir -p /bin; \
chmod 777 -R /bin; \
chown rootless:rootless /bin; \
touch /dev/stdout; \
chmod 777 -R /dev/stdout; \
chown rootless:rootless /dev/stdout
#
#
WORKDIR /var/www/html/magento2
VOLUME /var/myvolume
#
#
#STOPSIGNAL SIGQUIT
#
EXPOSE 80
#
CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
And here my docker-compose
version: "1.0"
services:
web:
user: "1000"
build: .
ports:
- "8080:80"
volumes:
- ".:/var/www/html/magento2:rw"
depends_on:
- mysql
mysql:
image: mariadb:10.6
container_name: mysql
restart: always
ports:
- "3306:3306"
environment:
- MYSQL_USER=root
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=magento
phpmyadmin:
container_name: phpmyadmin
restart: always
image: phpmyadmin/phpmyadmin:latest
environment:
- MYSQL_ROOT_PASSWORD=root
- PMA_USER=root
- PMA_PASSWORD=root
ports:
- "8081:80"
links:
- mysql:db
elasticsearch:
container_name: elasticsearch
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.0
environment:
- ELASTICSEARCH_URL=http://elasticsearch:9200
- node.name=elasticsearch
- cluster.name=es-cluster
- discovery.type=single-node
- bootstrap.memory_lock=true
- "ES_JAVA_OPTS=-Xms512m -Xmx512m"
ulimits:
memlock:
soft: -1
hard: -1
volumes:
- ./magento-es-data:/usr/share/elasticsearch/data
ports:
- 9200:9200
I have tried many things regarding the existing topics on that but nothing to do...
Don't judge the details on my dockerfile like my password or the comments, it's a test file nothing else:)
Thanks in advance for your help

Error no such file or directory when docker compose build

$docker-compose build
mv: cannot stat '/root/.symfony/bin/symfony': No such file or directory
ERROR: Service 'www_symfony_colcot' failed to build: The command '/bin/sh -c echo "ServerName localhost" >> /etc/apache2/apache2.conf && apt-get
Normaly auto generated by docker-compose.yml
docker-compose.yml :
version: "3.5"
services:
db_symfony_colcot:
image: mariadb:10.5.13
container_name: db_symfony_colcot
command: [ "--default-authentication-plugin=mysql_native_password" ]
restart: always
environment:
MYSQL_ROOT_PASSWORD: gsbgenerique
MYSQL_DATABASE: colcot
MYSQL_USER: gestionnaire
MYSQL_PASSWORD: gsbgenerique
volumes:
- ./initSQL/:/docker-entrypoint-initdb.d/
- "./datamysql-colcot:/var/lib/mysql"
ports:
- "3311:3306"
networks:
- dev-sym
www_symfony_colcot:
build: php
container_name: www_symfony_colcot
ports:
- "8094:80"
user: 0:0
volumes:
- ./php/vhosts:/etc/apache2/sites-enabled
- /home/marc/Desktop/colcot/colcot-2022/Colcot/:/var/www
restart: always
networks:
- dev-sym
networks:
dev-sym:
volumes:
db-data:
Dockerfile :
FROM php:7.4-apache
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf \
\
&& apt-get update \
&& apt-get install -y --no-install-recommends \
locales apt-utils git libicu-dev g++ libpng-dev libxml2-dev libzip-dev libonig-dev libxslt-dev unzip \
\
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& echo "fr_FR.UTF-8 UTF-8" >> /etc/locale.gen \
&& locale-gen \
\
&& curl -sS https://getcomposer.org/installer | php -- \
&& mv composer.phar /usr/local/bin/composer \
\
&& curl -sS https://get.symfony.com/cli/installer | bash \
&& mv /root/.symfony/bin/symfony /usr/local/bin \
&& useradd -m symfony -u 1001 \
\
&& docker-php-ext-configure \
intl \
&& docker-php-ext-install \
pdo pdo_mysql opcache intl zip calendar dom mbstring gd xsl \
\
&& pecl install apcu && docker-php-ext-enable apcu
WORKDIR /var/www/
Error caused by line :
&& mv /root/.symfony/bin/symfony /usr/local/bin \
How can i solve this error please. Btw im beginner with docker but this project was working since 5 month ago.
Already try :
Change mariadb version
All php version ( from 5.6 to 8 )
Change dockercompose version
Result : Still not working and same error
The command you are using to install symfony:
curl -sS https://get.symfony.com/cli/installer | bash
Is installing Symfony version 5. The files are located in symfony5 folder (notice the 5):
The Symfony CLI was installed successfully!
Use it as a local file:
/root/.symfony5/bin/symfony
So instead of running mv /root/.symfony/bin/symfony /usr/local/bin (.symfony folder does not exist), you should run:
mv /root/.symfony5/bin/symfony /usr/local/bin
By the way, as of 2022, using this script seems not to be the recommended method anymore: see https://symfony.com/download.
For info, the commit who changes the folder in the script from .symfony to .symfony5 is this one: https://github.com/symfony-cli/symfony-cli/commit/5301ebfa8f5918cae7fa0bf63c86f84dbd70f599.
I will add that in order to understand whether version 5 has changed to some other, you can look at the installer file (https://get.symfony.com/cli/installer) itself. Now (at the time of writing this comment) there is such information:
CLI_CONFIG_DIR=".symfony5"

Enable/Disable xDebug through Docker-Compose, is it possible?

I have the following Dockerfile:
FROM php:7.2-apache
RUN apt-get update && apt-get install -y \
zlib1g-dev \
git \
unzip \
&& rm -rf /var/lib/apt/lists/ \
&& docker-php-ext-install zip pdo_mysql bcmath \
&& a2enmod rewrite \
&& pecl install xdebug-2.9.0 redis \
&& docker-php-ext-enable xdebug redis \
&& mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" \
&& mv /var/www/html /var/www \
&& chown -R www-data:www-data /var/www/ \
&& ln -s /usr/local/bin/php /usr/bin/php
COPY --from=composer:1.9 /usr/bin/composer /usr/bin/composer
WORKDIR /var/www/drm-case
CMD ["docker/apache/bootstrap.sh"]
And this is the docker-compose.yml file that uses the previous Dockerfile to build the containers (not all the time though):
version: "2.4"
services:
case-v2-apache:
container_name: local-dev
image: local-dev:1.6 # increase this number when changing the Dockerfile
depends_on:
mysql-server:
condition: service_healthy
volumes:
- ${LOCAL_PATH}:/var/www:delegated
- ${LOCAL_PATH}/docker/apache/conf.d:/usr/local/etc/php/conf.d
- ${LOCAL_PATH}/docker/apache/conf-enabled/servername.conf:/etc/apache2/conf-enabled/servername.conf
- ${LOCAL_PATH}/docker/apache/sites-available/000-default.conf:/etc/apache2/sites-available/000-default.conf
ports:
- "8009:80"
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
build:
context: ${LOCAL_PATH:-./local-dev}
dockerfile: docker/apache/Dockerfile
networks:
- main
environment:
- VIRTUAL_HOST=local-dev.localhost
- COMPOSER_MEMORY_LIMIT=-1
- COMPOSER_AUTH=${COMPOSER_AUTH}
- COMPOSER_ALLOW_SUPERUSER=1
- PHP_IDE_CONFIG=serverName=local-dev
One of the files being copied in this line: ${LOCAL_PATH}/docker/apache/conf.d:/usr/local/etc/php/conf.d is xdebug related meaning is the one enabling and setting up the extension.
Wonder if there is a way to tell Docker by using ARG or ENV variables to enable/disable xDebug while starting the container? Has anyone tried such thing before? If so can you help me with some ideas?
You could simply move/rename the xdebug conf file based on a build arg…
FROM php:7.2-apache
RUN apt-get update && apt-get install -y \
zlib1g-dev \
git \
unzip \
&& rm -rf /var/lib/apt/lists/ \
&& docker-php-ext-install zip pdo_mysql bcmath \
&& a2enmod rewrite \
&& pecl install xdebug-2.9.0 redis \
&& docker-php-ext-enable xdebug redis \
&& mv "$PHP_INI_DIR/php.ini-development" "$PHP_INI_DIR/php.ini" \
&& mv /var/www/html /var/www \
&& chown -R www-data:www-data /var/www/ \
&& ln -s /usr/local/bin/php /usr/bin/php
COPY --from=composer:1.9 /usr/bin/composer /usr/bin/composer
RUN if [[ "$DISABLE_XDEBUG" == "1" ]] ; then mv "$PHP_INI_DIR/conf.d/xdebug.ini" "$PHP_INI_DIR/conf.d/xdebug.ini.disabled"
WORKDIR /var/www/drm-case
CMD ["docker/apache/bootstrap.sh"]
… or something like that?

docker The DSN string could not be parsed with CakePHP

I'm configuring CakePHP application with Docker.
I'm new to Docker and this is my first docker-compose.
Dockerfile
FROM php:7.2-apache
LABEL maintainer="Anuj Sharma <contact#anujsh.in>"
# Enable Apache Rewrite + Expires Module
RUN a2enmod rewrite expires
# Install dependencies
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
libyaml-dev \
zlib1g-dev \
libicu-dev \
libpq-dev \
libmcrypt-dev \
mysql-client \
g++ \
git \
libzip-dev \
zip \
unzip \
&& rm -r /var/lib/apt/lists/* \
&& pecl install mcrypt-1.0.1 \
&& docker-php-ext-install opcache \
&& docker-php-ext-configure intl \
&& docker-php-ext-install intl \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-configure zip --with-libzip \
&& docker-php-ext-install zip \
&& docker-php-ext-configure pdo_mysql --with-pdo-mysql=mysqlnd \
&& docker-php-ext-install -j$(nproc) gd \
&& docker-php-ext-install mbstring pcntl pdo_mysql pdo_pgsql pgsql \
&& docker-php-ext-enable mcrypt \
&& docker-php-ext-enable intl
# Install composer
#RUN curl -sS https://getcomposer.org/installer | php -- --install -dir=/usr/bin/ --filename=composer
RUN curl -sS https://getcomposer.org/installer | php && mv composer.phar /usr/local/bin/composer
# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
echo 'opcache.enable_cli=1'; \
echo 'upload_max_filesize=128M'; \
echo 'post_max_size=128M'; \
echo 'extension=intl.so'; \
} > /usr/local/etc/php/conf.d/php-recommended.ini
RUN pecl install apcu \
&& pecl install yaml \
&& docker-php-ext-enable apcu yaml
# Set our application folder as an environment variable
ENV APP_HOME /var/www/html
# Change uid and gid of apache to docker user uid/gid
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
# Change the web_root to cakephp /var/www/html/webroot folder
RUN sed -i -e "s/html/html\/webroot/g" /etc/apache2/sites-enabled/000-default.conf
# Copy source files and run composer
COPY . $APP_HOME
# Install all PHP dependencies
RUN composer install --no-interaction
# Change ownership of our applications
RUN chown -R www-data:www-data $APP_HOME
NOTE: I have copied commands from different sources to generate above Dockerfile.
docker-compose.yml
version: "3.1"
# Define all services
services:
# Our service is called CakePHP ;-)
cakephp:
# We want to use the image which is build from our Dockerfile
build: .
# Apache is running on port 80 but we want to expose this to port 4000 on our local machine
ports:
- "4000:80"
# We depending on the mysql backend
depends_on:
- mysql
volumes:
- .:/var/www/html/
environment:
- SECURITY_SALT=070q78he40qfw475q0q7v0wt7vfqw7vw87qw8dpowe7rfpwq437
- DATABASE_URL=mysql
- MYSQL_USERNAME=root
- MYSQL_PASSWORD=root
- MYSQL_DATABASE=cakephp
mysql:
# We use the mysql base image, version 5.7
image: mysql:5.7
# We mount a datavolume to make sure we don't loose data
volumes:
- cap_mysql_data:/var/lib/mysql
# Setting some env vars to create the DB
environment:
- MYSQL_ROOT_PASSWORD=root
- MYSQL_DATABASE=cakephp
volumes:
cap_mysql_data:
When I run
docker-compose build
It all goes well. But when I run to migrate the migrations
docker-compose run cakephp bin/cake migrations migrate
It gives error as
Exception: The DSN string 'mysql' could not be parsed. in [/var/www/html/vendor/cakephp/cakephp/src/Core/StaticConfigTrait.php, line 292]
The app.php file of CakePHP have configuration for datasource
'username' => env('MYSQL_USERNAME', 'root'),
'password' => env('MYSQL_PASSWORD', ''),
'database' => env('MYSQL_DATABASE', 'cakephp'),
'url' => env('DATABASE_URL', null),
The DATABASE_URL environment variable is expected to hold a DSN (data source name) string, mysql isn't such a string, this is what a DSN looks like:
mysql://user:pass#localhost:3306/database?encoding=utf8&timezone=UTC&cacheMetadata=true
The parts are basically as follows:
<driver>://<username>:<password>#<host>:<port>/<database>?<options>
If you don't actually want to use a DSN, then do not specify the DATABASE_URL variable.
See also
Cookbook > Database Access & ORM > Database Basics > Configuration
API > \Cake\Datasource\ConnectionManager::parseDsn()

Why are environment variables not being set inside of my docker container?

I have the following in my 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/
My DOCKERFILE has the following:
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"]
When I run docker-compose --verbose up -d I notice that there are no env vars passed in for my php container. I've verified that those env vars are set on my host, and they are passed in for all of my other containers without fail. Anyone have any ideas?
EDIT: Strangely enough, I've also noticed that /proc/$PID/environ (where $PID is the PID of the php container [obtained by running docker inspect --format "{{.State.Pid}}" php] on the host machine is empty.

Resources