我在ubuntu和mac os上安装了docker。 “docker-composer up
”命令在ubuntu和mac上按预期工作。
但是在Windows 8上,我安装了docker工具箱并运行“docker-compose up
”命令。我在创建php-container时遇到错误。
以下是错误的屏幕截图:
下面是docker-compose.yml文件
version: "3.2"
services:
php:
build: './php/'
container_name: php-container
networks:
- backend
volumes:
- ./code/:/var/www/html/
- ./php/config/php.ini:/usr/local/etc/php/conf.d/php.ini
- ./php/config/mcrypt.so:/usr/local/lib/php/extensions/no-debug-non-zts-20151012/mcrypt.so
links:
- redis:redis
nginx:
container_name: nginx-container
image: nginx:latest
depends_on:
- php
- mysql
ports:
- "80:80"
networks:
- frontend
- backend
volumes:
- ./code/:/var/www/html/
- ./site.conf:/etc/nginx/conf.d/default.conf
links:
- php
mysql:
image: mysql:5.6.40
container_name: mysql-container
networks:
- backend
environment:
- MYSQL_ROOT_PASSWORD=password
volumes:
- /var/lib/postgresql/data
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin-container
networks:
- backend
depends_on:
- mysql
links:
- mysql:mysql
ports:
- 8088:80
environment:
PMA_HOST: mysql
MYSQL_USERNAME: abcxyz
MYSQL_ROOT_PASSWORD: 321654987
networks:
frontend:
backend:
下面是php的dockerfile
FROM php:7.0.32-fpm
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
&& docker-php-ext-install -j$(nproc) iconv \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
RUN docker-php-ext-install mysqli
RUN pecl install -o -f redis \
&& rm -rf /tmp/pear \
&& docker-php-ext-enable redis
RUN apt-get -qq update && apt-get -qq -y install \
automake \
cmake \
g++ \
git \
libicu-dev \
libmagickwand-dev \
libpng-dev \
librabbitmq-dev \
libreadline-dev \
pkg-config \
ssh-client \
supervisor \
zlib1g-dev \
&& docker-php-ext-install \
bcmath \
gd \
intl \
opcache \
pdo_mysql \
sockets \
zip \
&& git clone git://github.com/alanxz/rabbitmq-c.git \
&& cd rabbitmq-c \
&& mkdir build && cd build \
&& cmake -DENABLE_SSL_SUPPORT=OFF .. \
&& cmake --build . --target install \
&& pecl install amqp imagick xdebug igbinary \
&& docker-php-ext-enable amqp imagick xdebug igbinary \
&& version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
&& curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
&& mkdir -p /tmp/blackfire \
&& tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
&& printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
&& curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \
&& mv /tmp/blackfire/blackfire /usr/bin/blackfire \
&& rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update && apt-get install -y \
libmcrypt-dev \
&& docker-php-ext-install -j$(nproc) iconv mcrypt \
&& docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
&& docker-php-ext-install -j$(nproc) gd
RUN apt-get install -y libxslt-dev
RUN apt-get install -y zlibc
RUN docker-php-ext-install xsl
RUN curl -s https://getcomposer.org/installer | php
RUN mv composer.phar /usr/local/bin/composer
同样的错误......
在我的情况下在docker-compose.yml
文件中
apache:
build: '.\apache\'
container_name: apache-container
depends_on:
- php
- mysql
networks:
- frontend
- backend
ports:
- "80:80"
volumes:
- .\public_html\:/var/www/html/
- .\apache\demo.apache.conf:/usr/local/apache2/conf/demo.apache.conf
- .\apache\custom.conf:/usr/local/apache2/conf/test.conf
在最后一行- .\apache\custom.conf:/usr/local/apache2/conf/test.conf
我正在复制自定义conf来测试docker中的conf。这是按预期工作的。
但是当我将test.conf更改为httpd.conf并运行docker-compose up
时,会出现同样的错误,如上面问题中的屏幕截图所示。
所以,如果我检查apache容器上的文件,我可以看到test.conf文件中还有httpd.conf文件,但是当我尝试替换httpd.conf文件时它显示错误。