LoginSignup
3
5

More than 3 years have passed since last update.

Mac docker-compose up でエラーが発生した話

Last updated at Posted at 2020-08-08

目的

  • dockerのコンテナを起動しようとした時にエラーが発生し解決した話をまとめる

実施環境

問題までの経緯

  1. dockerファイルが存在するディレクトリに移動し下記コマンドを実行してコンテナの起動を試みた。

    $ docker-compose up -d
    

問題

  1. 下記のエラーが発生した。

    ERROR: for コンテナ名  Cannot start service php: Ports are not available: listen tcp 0.0.0.0:80: bind: address already in use
    
    ERROR: for php  Cannot start service php: Ports are not available: listen tcp 0.0.0.0:80: bind: address already in use
    ERROR: Encountered errors while bringing up the project.
    

解決までの経緯

  1. 下記コマンドを実行して使用されているポートを調べた。apacheが動いている様である。

    $ sudo lsof -i -P | grep ":80"
    > httpd      339            _www    4u  IPv6 0x666e8ad53dfbd5c3      0t0  TCP *:80 (LISTEN)
    
  2. 下記コマンドを実行してhttpdを止めようとした。(皆さんは下記コマンドでhttpdを止められるはずである。)

    $ sudo service httpd stop
    
  3. 先のコマンドを実行したがhttpdはすでに停止している旨の出力が得られた。

  4. Macローカルのhttpdは現在使用しておらず強制停止しても問題ないこと、Dockerのコンテナ起動を急いでいたことから下記コマンドを実行してヒットしたプロセスをkillした。

    $ kill -l 339
    
  5. 下記コマンドを実行したら正常にコンテナが起動した。

    $ docker-compose up -d
    
  6. コマンドだけではなく、アクティビティモニターにてhttpdを検索して強制終了する方法も実施することができる。

3
5
2

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
5