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

标签 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

最佳答案

看看本文是否可以帮助您:“LAMP ( Linux, Apache, MariaDB, PHP ) stack Docker image deployment

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

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

At this stage we are ready to deploy “linuxconfig/lamp” docker image:


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

这意味着您要将主机目录html装入linuxconfig/lamp容器文件夹/var/www/html。 (请参阅“Mount a host directory as a data volume”)

关于php - Docker LAMP堆栈-保存PHP项目的位置在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41529969/

相关文章:

apache - 将特定 URL 重定向到带有 SEO 名称的 SSL 版本

javascript - 隐藏 slider 中具有相同 id 的空图像

php - 在 CentOS5 上为 PHP5 启用 PDO,其中 PHP 配置为 '--disable-pdo'

java - 从 PHP 调用 jar

apache - 使用 Flume 将推文写入 HDFS 对 Agent 不起作用

apache - 我在哪里可以找到 CentOS 服务器中的 ssl.conf 文件?

用于 elasticsearch 7.0.1 和 kibana 7.0.1 的 docker-compose.yml

windows - 容器(Docker)和 IIS 之间的区别

docker - 在 Jenkins 声明式管道中将人工制品从一个代理复制到另一个代理

php - 服务之间应如何通信?