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

So at my http://172.17.0.2/, 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 <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"]

EDIT:

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

And:

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

I go to my browser at: http://172.17.0.2:32769/

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/
    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
    

    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")

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算