0.0.0.0没有在Docker中发送任何数据

时间:2018-05-03 13:59:30

标签: docker

我正在尝试使用Docker设置我的PHP应用程序。它成功构建,但是当我点击浏览器时 - 它显示0.0.0.0 didn’t send any data.

这是我的docker-compose.yml ::

version: '2'
services:

# The Application
app:
  build:
    context: ./
    dockerfile: app.dockerfile
working_dir: /Users/sr/Sites/zogo-commerce/public
volumes:
  - ./:/var/www/zogo-commerce/public
environment:
  - "DB_PORT=3306"
  - "DB_HOST=127.0.0.1"

# The Web Server
web:
  build:
    context: ./
    dockerfile: web.dockerfile
working_dir: /Users/sr/Sites/zogo-commerce/public
volumes_from:
  - app
ports:
  - 9090:80

# The Database
database:
  image: mysql:5.6
  volumes:
    - dbdata:/usr/local/bin/mysql
environment:
  - "MYSQL_DATABASE=zogo_commerce"
  - "MYSQL_USER=root"
  - "MYSQL_PASSWORD=root1234"
  - "MYSQL_ROOT_PASSWORD=root1234"
ports:
    - "33061:3306"
volumes:
 dbdata:

档案web.dockerfile ::

FROM nginx:1.10

ADD vhost.conf /etc/nginx/conf.d/default.conf

档案app.dockerfile ::

FROM php:7.0.4-fpm

RUN apt-get update && apt-get install -y libmcrypt-dev \
mysql-client libmagickwand-dev --no-install-recommends \
&& pecl install imagick \
&& docker-php-ext-enable imagick \
&& docker-php-ext-install mcrypt pdo_mysql

虚拟主机文件vhost.conf ::

server {
listen       8080;
server_name  zogo-commerce.local;

root /var/www/zogo-commerce/public;

index index.php index.html index.htm;

try_files $uri $uri/ /index.php?$args;

location ~ \.php$ {
    fastcgi_pass   127.0.0.1:9000;
    fastcgi_index  index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include        fastcgi_params;
    fastcgi_read_timeout 600;
}

}

这是我的容器:

CONTAINER ID        IMAGE               COMMAND                  
CREATED             STATUS                           PORTS                           
NAMES
11d6a74becfe        zogo-commerce_web   "nginx -g 'daemon of…"   5 
minutes ago       Up 5 minutes                     443/tcp, 
0.0.0.0:9090->80/tcp   zogo-commerce_web_1
032249f95de8        zogo-commerce_app   "php-fpm"                5 
minutes ago       Up 6 minutes                     9000/tcp                        
zogo-commerce_app_1
9515f4708708        mysql:5.6           "docker-entrypoint.s…"   18 
minutes ago      Up 6 minutes                     0.0.0.0:33061- 
>3306/tcp         zogo-commerce_database_1

似乎构建是可以的,但在brwser http://0.0.0.0:9090/显示ERROR。

如何解决此问题以使其可行?在此先感谢::

这是我的档案:

docker-compose.yml: https://pastebin.com/bZUHMRvr
app.dockerfile: https://pastebin.com/bUKZ2suj
web.dockerfile: https://pastebin.com/0qbCGnWm
vhost.conf: https://pastebin.com/MnZkbTe2
docker-compose up :: Error -> https://pastebin.com/6HEgpJk1

2 个答案:

答案 0 :(得分:1)

此0.0.0.0不是有效的IP地址,而是a non-routable meta-address 您的应用程序可通过端口9090上的计算机IP地址/主机名访问。

如果您不确定,您的主机名是什么,您可以在linux中运行;

hostname

答案 1 :(得分:0)

它不仅是码头问题。看看vhost.conf,你在那里打开8080,这意味着httpd服务器监听8080端口,但是在docker-compose.yml中你将主机端口9090映射到容器端口80.你应该打开8080而不是80.

Dockerfile还有另一个问题。你没有暴露任何端口。你应该暴露8080

希望一切顺利