3
3

More than 5 years have passed since last update.

docker-composeでブリッジネットワークのIPを変える

Posted at

過去に何度もdocker0のIPアドレス帯を変えてきたが、docker-composeを使うと、docker0が設定されていても個別にブリッジネットワークを作成するようだ。そこでまた172.17....のネットワークが出現してしまう現象が発生した。

例によって私の環境は172.17.X.Xの帯域を使っているので接続不能に。ということで、また調査を行いました。

設定方法

いろいろ試したが、下記のようにdefaultネットワークのsubnetを設定すれば良い。

version: '2'

services:
....
networks:
  default:
    driver: bridge
    ipam:
      driver: default
      config:
        - subnet: 192.168.201.0/24

注意としてdocker0のネットワークとは別のsubnetを指定する必要がある。

参考

docker-compose up するときに subnet を指定する
https://qiita.com/manabuishiirb/items/293d5d5a3ec7d5328cc5

Docker container networking – Docker Documentation
http://docs.docker.jp/compose/compose-file.html#network-configuration-reference

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