Symfony服务器:在php Docker容器中运行 [英] Symfony server:run in php Docker container

查看:72
本文介绍了Symfony服务器:在php Docker容器中运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个php docker容器,这是我的symfony项目。

I have a php docker container where is my symfony project.

这是我的 docker-compose.yml

php-fpm:
    build: ./php
    container_name: php-fpm
    links:
        - db
    ports:
        - 9000:9000
        - 8448:8448
        - 8000:8000
    working_dir: /var/www/html/
    volumes:
        - ../app:/var/www/html
    volumes_from:
        - data
    tty: true
    env_file:
        - ./docker.env
    entrypoint: /entrypoint.sh

我想使用以下命令启动symfony项目:此命令:

I want to launch my symfony project with this command:

php bin/console server:run localhost:8000

但是当我想访问URL时它不起作用。我收到此错误消息:

But it's not working when I want to access the url. I have this error message:


本地主机页面无法正常工作

The localhost page isn’t working

本地主机未发送任何数据。

localhost didn’t send any data.

我该如何解决?

PS:我在Mac上使用docker

PS: I'm using docker for mac

php bin / console -vvv服务器:运行本地主机:8000 输出:


[2016-08-06 14:09:53] php.DEBUG:fsockopen():无法连接至
本地主机:8000(拒绝连接)
{ type:2, file: / var / www / html / symfony-test / vendor / symfony / symfony / src / Symfony / Bundle / FrameworkBundle / Command / ServerCommand.php, line:59, level:28928}

[2016-08-06 14:09:53] php.DEBUG: fsockopen(): unable to connect to localhost:8000 (Connection refused) {"type":2,"file":"/var/www/html/symfony-test/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Command/ServerCommand.php","line":59,"level":28928}

                                                                                                                      [OK] Server running on http://localhost:8000                          

//用CONTROL-C退出服务器。

// Quit the server with CONTROL-C.

RUN'/ usr / local / bin / php''-S''localhost:8000'
'/ var / www / html / symfony-test /vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php'

RUN '/usr/local/bin/php' '-S' 'localhost:8000' '/var/www/html/symfony-test/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Resources/config/router_dev.php'


推荐答案

以下是@Alex Blex答案:在所有接口上运行它时都可以使用。

Following @Alex Blex answer: It works when you run it on all interfaces.

 php bin/console server:run 0.0.0.0:8000

这篇关于Symfony服务器:在php Docker容器中运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆