LoginSignup
3
1

More than 3 years have passed since last update.

【WSL2 Docker】 「docker-compose up」にてPorts are not availableエラーが発生したとき

Posted at

概要

  • docker upを実行したときに
ERROR: for app  Cannot start service app: Ports are not available: listen tcp 0.0.0.0:50080: bind: An attempt was made to access a socket in a way forbidden by its access permissions.
ERROR: Encountered errors while bringing up the project.

そのエラーが出たときに調べたことと対応について記録します。

本文

調べたこと

原因についていくつかの候補が上がりました。

Portが埋まっている

Portがほかで使われている可能性を考え、netstat -oaで確認しましたが、確認ができませんでした。

対応

docker-compose.ymlに記載したPort番号を変更しました。50080で最初設定しており、50081に変更しても結果が変わらなかったため、カーネルに占有されていることが候補としてあがりました。
以下に記載した資料によると、49152以降の番号を使うとエフェメラルポートと被りそうです。
なので、初期状態から49152よりも前のPort番号を使えばよさそうです。

参考

3
1
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
3
1