Help us understand the problem. What is going on with this article?

docker-composeでdriver failed programming external connectivity on endpointが出た場合の覚書

前置き

docker-compose runでdjango環境を構築しようとした際に出たエラーの覚書。
dockerがポートを掴んでいて解放していないという原因もあるが、ホスト側とバッティングしている可能性もある。dockerさんが解放していない場合はdockerの再起動で治る。

発生した現象

> docker-compose run web django-admin.py startproject mysite .
  :
(中略)
  :
b64ec62ca852: Pull complete
42323e351ef3: Pull complete
Creating mysite.db ...
Pulling db (mysql:5.7)...
Creating hoge.db ... error

ERROR: for hoge.db  Cannot start service db: driver failed programming external connectivity on endpoint hoge.db (f683296d4aac32cfe3ca117c6c8464169624860afe875bedccf533d3fa1aa90e): Error starting userland proxy: Bind for 0.0.0.0:3306: unexpected error Permite.db (f683296d4aac32cfe3ca117c6c8464169624860afe875bedccf533d3fa1aa90e): Error starting userland proxy: Bind for 0.0.0.0:3306: unexpected error Permission denied

  :
(中略)
  :
ERROR: for db  Cannot start service db: driver failed programming external connectivity on endpoint hoge.db (48963bd165e4acf284fdef661b0f6b92d4c80bba8e5826804b54294b92eef31d): Error starting userland proxy: Bind for 0.0.0.0:3306: unexpected error Permission denied
ERROR: Encountered errors while bringing up the project.

dockerでdb用のvolumeを作成して、コンテナでvolumeを指定しようとしたら発生。

原因

dbコンテナで指定していたポートがホスト側で使用されていた。

  :
    ports:
      - 3306:3306
  :

ホスト側

>netstat -ano|find ":3306"
  TCP         0.0.0.0:3306           0.0.0.0:0              LISTENING       6692
  TCP         0.0.0.0:33060          0.0.0.0:0              LISTENING       6692
  TCP         [::]:3306              [::]:0                 LISTENING       6692
  TCP         [::]:33060             [::]:0                 LISTENING       6692

ホスト側でお試しで入れていたMySQL8.0のポートとバッティングしていたのでアンインストール。
ホスト側を変えたくない場合はdocker-compose側のポートを変えてあげるといい。

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away