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?

【Docker】ポート番号がすでにあると言われた場合

Posted at

問題

すでにそのポート番号はあるよと言われた場合
これ→port is already allocated

docker-compose up --build -d
↓
↓
エラー文
Error response from daemon: driver failed programming external connectivity on endpoint umarche-db (9f00569d16d49aa612387d7f1c675af9c6cc2bc7453db9dbb76caeae4ddfa6ae): Bind for 0.0.0.0:3306 failed: port is already allocated

解決方法

  db:
    container_name: umarche-db
    # Mac M1チップユーザー
    platform: linux/x86_64
    image: mysql:5.7
    # コンテナの環境変数を指定
    environment:
      MYSQL_ROOT_PASSWORD: root
      TZ: 'Asia/Tokyo'
    volumes:
      - ./db:/var/lib/mysql
    restart: always
    ↓⭐️ここ
    ports:
      // - 3306:3306
      - 13306:3306

回避策としてはhost側portを別のportにmappingする

この13306のところをprojectごとに変えれば Bind for 0.0.0.0:3306 failed: port is already allocated. は発生しなくなる

参考

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?