我已经在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/上,我可以看到以下默认页面:
但是我在哪里可以找到它的位置,以便可以将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/
我收到此错误:
最佳答案
看看本文是否可以帮助您:“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/