“ docker-compose up”错误:无法启动服务php:OCI运行时创建失败:container_linux.go:345

时间:2019-04-22 06:09:20

标签: php docker docker-compose dockerfile

我已经在 ubuntu mac os 上安装了docker。 “ docker-composer up”命令在ubuntu和Mac上正常运行。

但是在 Windows 8 上,我已经安装了docker工具箱并运行“ docker-compose up”命令。创建php容器时出现错误

  

下面是错误的屏幕截图:

enter image description here

  

下面是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

1 个答案:

答案 0 :(得分:1)

  

这里有同样的错误...

在我的情况下,在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时,会出现相同的错误,如上面问题中的屏幕快照所示。

错误: Error screenshot

因此,如果我检查apache容器上的文件,我可以看到test.conf文件中还有httpd.conf文件,但是当我尝试替换httpd.conf文件时,它显示错误