Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
308 views
in Technique[技术] by (71.8m points)

php - A little problem with starting Laravel server in docker container

[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE              COMMAND                  CREATED          STATUS          PORTS                               NAMES
369caac73fe5   php:7.4.6-apache   "docker-php-entrypoi…"   48 minutes ago   Up 23 minutes   80/tcp, 0.0.0.0:8000->8000/tcp      web_laravel

I have deployed the Laravel 8.x source code in web_laravel docker. I did not get any error while running composer update and php artisan serve.

# php artisan serve
Starting Laravel development server: http://127.0.0.1:8000
[Mon Jan  20:01:04 2021] PHP 7.4.6 Development Server (http://127.0.0.1:8000) started

But, when I access 192.168.1.xx:8000 in browser, I get the following error.

192.168.1.xx refuses to connect

I tried to ping 192.168.1.xx, it works fine. But, I got the following error when using telnet.

$ telnet 192.168.1.xx 8000
Trying 192.168.1.xx...
telnet: Unable to connect to remote host: Connection refused

It seems that I am having a little problem with starting Laravel server in docker. Could anybody help me?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You must specify where you should run your laravel application , by default it's run on 127.0.0.1 try run it by php artisan serve --host 192.168.1.xx


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...