2017-01-08 06:00
浏览 153

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

I have my LAMP stack installed already before Docker's. And I am using this image to build and run my Docker's LAMP stack:

$ docker pull linuxconfig/lamp

After all are downloaded and installed:

$ 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 Set the 'ServerName' directive globally to suppress this message

So at my, I can see this default page:

enter image description here

But where can I locate its location so that I can put my PHP projects in there?

This the DockerFile from that image:

FROM linuxconfig/apache
MAINTAINER Lubos Rendek <>

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


$ sudo docker port lamp
80/tcp ->
3306/tcp ->

I go to my browser at:

I get this error:

enter image description here

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

  • dongzi9196 2017-01-08 06:37

    See if this article can help: "LAMP ( Linux, Apache, MariaDB, PHP ) stack Docker image deployment"

    Save index.php file and within a new html directory.
    Alternatively, html directory may contain your desired PHP application:

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

    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

    That means you are mounting your host directory html into the linuxconfig/lamp container folder /var/www/html. (see "Mount a host directory as a data volume")

    解决 无用
    打赏 举报

相关推荐 更多相似问题