可以在生产主机上使用docker运行php站点

时间:2015-02-13 22:40:42

标签: php docker

我在Digital Ocean盒子上只有这个问题。在我的笔记本电脑上,我可以看到该网站在制作时,我试图卷曲我的网站时得到500。 如果我从外面的世界击中该码头的网关,我可以看到我的网站。但那不是解决方案。我想将我的dns指向主机的ip而不是docker网关。

dockerfile

FROM phusion/baseimage:0.9.15

ENV HOME /root

RUN /etc/my_init.d/00_regen_ssh_host_keys.sh

CMD ["/sbin/my_init"]

# Nginx-PHP Installation
RUN apt-get update
RUN apt-get install -y vim curl wget build-essential python-software-properties
RUN add-apt-repository -y ppa:ondrej/php5
RUN add-apt-repository -y ppa:nginx/stable
RUN apt-get update
RUN apt-get install -y --force-yes php5-cli php5-fpm php5-mysql php5-pgsql php5-sqlite php5-curl\
                       php5-gd php5-mcrypt php5-intl php5-imap php5-tidy

RUN sed -i "s/;date.timezone =.*/date.timezone = UTC/" /etc/php5/fpm/php.ini
RUN sed -i "s/;date.timezone =.*/date.timezone = UTC/" /etc/php5/cli/php.ini

RUN apt-get install -y nginx

RUN echo "daemon off;" >> /etc/nginx/nginx.conf
RUN sed -i -e "s/;daemonize\s*=\s*yes/daemonize = no/g" /etc/php5/fpm/php-fpm.conf
RUN sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/" /etc/php5/fpm/php.ini

RUN mkdir -p        /var/www
ADD build/default   /etc/nginx/sites-available/default
RUN mkdir           /etc/service/nginx
ADD build/nginx.sh  /etc/service/nginx/run
RUN chmod +x        /etc/service/nginx/run
RUN mkdir           /etc/service/phpfpm
ADD build/phpfpm.sh /etc/service/phpfpm/run
RUN chmod +x        /etc/service/phpfpm/run

EXPOSE 80
# End Nginx-PHP

RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

构建并运行

docker build -t donate-home .
docker run --name donate-home -d -p 3001:80 -v $(pwd)/www:/var/www:rw donate-home /sbin/my_init --enable-insecure-key
生产主机上的

curl -i localhost:3001

HTTP/1.1 500 Internal Server Error

docker logs donate-home

*** Installing insecure SSH key for user root                                                                                                                                          │····························
Creating directory /root/.ssh...                                                                                                                                                       │····························
Editing /root/.ssh/authorized_keys...                                                                                                                                                  │····························
Success: insecure key has been added to /root/.ssh/authorized_keys                                                                                                                     │····························
                                                                                                                                                                                       │····························
+------------------------------------------------------------------------------+                                                                                                       │····························
| Insecure SSH key installed                                                   |                                                                                                       │····························
|                                                                              |                                                                                                       │····························
| DO NOT expose port 22 on the Internet unless you know what you are doing!    |                                                                                                       │····························
|                                                                              |                                                                                                       │····························
| Use the private key below to connect with user root                         |                                                                                                        │····························
+------------------------------------------------------------------------------+                                                                                                       │····························
                                                                                                                                                                                       │····························
-----BEGIN RSA PRIVATE KEY-----                                                                                                                                                        │····························
<content of private key>
-----END RSA PRIVATE KEY-----                                                                                                                                                          │····························
                                                                                                                                                                                       │····························
                                                                                                                                                                                       │····························
*** Running /etc/my_init.d/00_regen_ssh_host_keys.sh...                                                                                                                                │····························
*** Running /etc/rc.local...                                                                                                                                                           │····························
*** Booting runit daemon...                                                                                                                                                            │····························
*** Runit started as PID 17                                                                                                                                                            │····························
[13-Feb-2015 22:13:12] NOTICE: fpm is running, pid 31                                                                                                                                  │····························
[13-Feb-2015 22:13:12] NOTICE: ready to handle connections

0 个答案:

没有答案