Docker LAMP堆栈 - 保存PHP项目的位置在哪里?

时间:2017-01-08 06:00:44

标签: php apache docker dockerfile lamp

我已经在Docker之前安装了LAMP堆栈。我正在使用这个图像来构建和运行我的Docker的LAMP堆栈:

$ docker pull linuxconfig/lamp

下载并安装完毕后:

$ docker run -it linuxconfig/lamp /bin/bash
root@2e80dfd55a6e:/# service apache2 start
[....] Starting web server: apache2AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.2. Set the 'ServerName' directive globally to suppress this message

因此,在我的http://172.17.0.2/,我可以看到默认页面:

enter image description here

但是我在哪里可以找到它的位置,以便我可以将我的PHP项目放在那里?

来自该图像的DockerFile:

FROM linuxconfig/apache
MAINTAINER Lubos Rendek <web@linuxconfig.org>

ENV DEBIAN_FRONTEND noninteractive

# Main package installation
RUN apt-get update
RUN apt-get -y install supervisor libapache2-mod-php5 php5-mysql mysql-server

# Extra package installation
RUN apt-get -y install php5-gd php-apc php5-mcrypt

# Configure MySQL
RUN sed -i 's/bind-address/#bind-address/' /etc/mysql/my.cnf

# Include supervisor configuration
ADD supervisor-lamp.conf /etc/supervisor/conf.d/
ADD supervisord.conf /etc/supervisor/

# Include PHP Info page
ADD index.php /var/www/html/index.php

# Create new MySQL admin user
RUN service mysql start; mysql -u root -e "CREATE USER 'admin'@'%' IDENTIFIED BY 'pass';";mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO 'admin'@'%' WITH GRANT OPTION;"; 

# Allow ports
EXPOSE 80 3306

# Start supervisor
CMD ["supervisord"]

编辑:

$ sudo docker run --name=lamp -dP -v $PWD/html:/var/www/html linuxconfig/lamp
c2d1687aef21f8a12a7fbb31bf8cf71c1e5adabf381bc6d70e8804c6663f0bc0

$ sudo docker port lamp
80/tcp -> 0.0.0.0:32769
3306/tcp -> 0.0.0.0:32768

我转到我的浏览器:http://172.17.0.2:32769/

我收到此错误:

enter image description here

1 个答案:

答案 0 :(得分:3)

查看本文是否有用:&#34; LAMP ( Linux, Apache, MariaDB, PHP ) stack Docker image deployment&#34;

保存index.php个文件并保存在新的html目录中 或者,html目录可能包含您所需的PHP应用程序:

$ mkdir html
$ vi html/index.php
$ ls html/
index.php
  

在此阶段,我们已准备好部署“linuxconfig/lamp”泊坞窗图片:

sudo docker run --name=lamp -dP -v $PWD/html:/var/www/html linuxconfig/lamp

这意味着您将主机目录html挂载到linuxconfig/lamp容器文件夹/var/www/html。 (参见&#34; Mount a host directory as a data volume&#34;)