18
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Laravel on Docker で php artisan serve するとlocalhost:8000が見れない

Last updated at Posted at 2018-02-26

掲題の件の対処法。
dockerコマンドの-pオプション付与、もしくはdocker-compose.ymlのports設定はしてる前提。

素のphp artisan serveを叩いた場合、自分(localhost)以外からのアクセスを受け付けないようになっている。
Dockerコンテナ内でcurlすると正常なHTTPレスポンスが返ってくるはず。

docker exec YOUR_CONTAINER curl localhost:8000

というわけでコンテナの外からアクセスできるようにしてやる必要がある。
以下のオプションを付けると見れるようになる。

php artisan serve --host 0.0.0.0
18
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?