0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

コンテナを終了したのにポートが占有されたままになるのを解決する方法

Posted at

docker-composeを起動する際に、下記のようなメッセージが出て起動に失敗することがあります。
この場合だと、3306ポートが使用済みなので起動できないということですね。

Error response from daemon: driver failed programming external connectivity on endpoint api-mysql-1 (842426d34d674221b2e025551367628d2bc6ffd4ab4aae0eed927e6d6ecd3dca): Bind for 0.0.0.0:3306 failed: port is already allocated

そこで、一般的には3306ポートを使用している他のコンテナを探しそれを停止すれば問題は解決するはずなのですが、今回はそれでも解決しなかったので別の方法を試しました。

以下、手順です。

1.コンテナをすべて停止する。
起動中のすべてのコンテナを停止します。

2.Dockerのプロセスをすべて停止する。
タスクマネージャー(ctrl + shift + esc)を開き、Dockerと名前の付くものをすべて停止します。
・Docker Desktop
・Docker Desktop Backend
・Docker Desktop Extensions

3.WSLを停止する
Power shellで以下のコマンドを実行します。
wsl --shutdown

4.Docker Desktopを再起動する
いつも通りの方法でDocker Desktopを起動します。

5.再度docker-composeを実行する
これでうまくいっていれば無事に立ち上がると思います。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?