【问题标题】:My web docker container image not running我的 web docker 容器镜像没有运行
【发布时间】:2018-02-18 01:16:50
【问题描述】:

我尝试将 docker 用于 laravel 项目,并且我使用 Ubuntu 作为基础映像和 laravel 依赖,但在 docker-compose up 之后,只有 mysql 和 adminer 容器正在运行。我的 Dockerfile 和 docker-compose.yml 文件在下面

我的 Dockerfile

FROM ubuntu:16.04
Run apt-get update
RUN apt-get update \
&& apt-get install -y --no-install-recommends software-properties-common
RUN apt-get update 
RUN apt-get install -y apache2 
RUN apt-get install -y php7.0 php7.0-mysql php7.0-mbstring
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
RUN  apt-get update
RUN  apt-get install -y git zip unzip
RUN  apt-get update
COPY laravel/ /var/www/html/
COPY laravel//vhost.conf /etc/apache2/sites-available/000-default.conf
WORKDIR /var/www/html
RUN chown -R www-data:www-data /var/www/html \
&& a2enmod rewrite

****docker yml 文件****

version: '2'

services:

db:
 image: mysql
 environment:
  MYSQL_ROOT_PASSWORD: mysql
ports:
   - 8086:3306

adminer:
 image: adminer
 ports:
  - 8085:8080

web:
 image: laravel
ports:
  - 8889:80
volumes:
  - .bilbayt_admin/:/var/www/html/

【问题讨论】:

  • 您是否遇到任何错误? “码头工人日志img”
  • 不,我没有收到任何错误。
  • 对于 apache docker 的初学者,您需要一个入口点。

标签: docker laravel-5 docker-compose


【解决方案1】:

查看您的 Dockerfile,您需要 ENTRYPOINTCMD,通常添加为 Dockerfile 的最后几行。这些条目告诉映像在您docker run 时要运行哪个命令(这是通过docker-compose up 以迂回的方式完成的)。

【讨论】:

    【解决方案2】:

    你需要添加一个cmd来启动apache/一个入口点。

    最后像下面这样。

    CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]
    

    【讨论】:

      【解决方案3】:

      现在我的 Docker 文件看起来像这样并且可以正常工作

      FROM ubuntu:16.04 运行 apt-get update RUN apt-get update \
      && apt-get install -y --no-install-recommends software-properties-common
      运行 apt-get 更新
      运行 apt-get 安装
      -y apache2 运行 apt-get install -y php7.0 php7.0-mysql php7.0-mbstring
      运行 curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
      运行 apt-get 更新
      运行 apt-get install -y git zip unzip
      运行 apt-get 更新
      复制 。 /var/www/html
      复制 .docker/vhost.conf /etc/apache2/sites-available/000-default.conf
      工作目录 /var/www/html
      运行 chown -R www-data:www-data /var/www/html \ && a2enmod 重写
      CMD ["/usr/sbin/apache2ctl", "-D", "FOREGROUND"]

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-09-14
        • 1970-01-01
        • 2021-11-06
        • 2019-10-09
        • 2022-10-15
        • 2016-09-08
        • 1970-01-01
        相关资源
        最近更新 更多