1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

boot2dockerを利用したIPを変えたい

Posted at

ぽえむ

あるイントラネット内、 re:dashのDocker版をインストールし、DB接続して使おうとした。
しかし、DB側のIP帯が、 172.17.xxx.xxx

boot2dockerのブリッジ接続で利用しているデフォルトIP帯。

172.17.0.0/16

docker-network-bridge
$ docker network inspect bridge
[
    {
        "Name": "bridge",
        "Id": "37262f6715263e87db026d5501a08a3c24db5243e1235696d19f762ac2bac69a",
        "Scope": "local",
        "Driver": "bridge",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "172.17.0.0/16",
                    "Gateway": "172.17.0.1"
                }
            ]
        },
        "Internal": false,
        "Containers": {},
        "Options": {
            "com.docker.network.bridge.default_bridge": "true",
            "com.docker.network.bridge.enable_icc": "true",
            "com.docker.network.bridge.enable_ip_masquerade": "true",
            "com.docker.network.bridge.host_binding_ipv4": "0.0.0.0",
            "com.docker.network.bridge.name": "docker0",
            "com.docker.network.driver.mtu": "1500"
        },
        "Labels": {}
    }
]

完全にかぶってますなぁ...

環境

docker-machine -> Virtualbox -> docker-compose -> re:dash

解決策

--fixed-cidr, --bip を追加する

ただし、Linuxのやり方と違うので注意。Linuxのばっかり載ってるんですわ。ひどいですわ。
boot2dockerが特殊なのだろうなぁ。

Linux版の参考: http://knowledge.sakura.ad.jp/knowledge/4786/

$ docker-machine ssh redash
$ cat /var/lib/boot2docker/profile
EXTRA_ARGS='
--label provider=virtualbox

'

$ vi /var/lib/boot2docker/profile
EXTRA_ARGS='
--label provider=virtualbox
--fixed-cidr=192.168.100.0/24
--bip=192.168.100.1/24
'

以下、ボツ案

docker network で頑張ろうとしたパターン

docker-network
$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
dd738187eba6        bridge              bridge              local ←既にあるbridge
048888e14045        host                host                local               
a628ca4f5158        none                null                local   

既にある bridge のIP帯変えよう

変更不可

既にある bridge 消そう

$ docker network rm bridge
Error response from daemon: bridge is a pre-defined network and cannot be removed

消せない

新しいネットワーク作ってそちらを通そう

$ docker network create --driver bridge --subnet 192.168.101.0/24 --gateway=192.168.101.1 \
-o "com.docker.network.bridge.enable_icc"="true" \
-o "com.docker.network.bridge.enable_ip_masquerade"="true" \
-o "com.docker.network.bridge.host_binding_ipv4"="0.0.0.0" \
-o "com.docker.network.driver.mtu"="1500" \
redash
docker-compose.yml
version: '2'
services: 
    xxxxxx
networks:
  default:
    external:
      name: redash

同じIP帯が消えないので、結局意味ない。(気づくの遅い)

参考

http://superbrothers.hatenablog.com/entry/2014/06/19/234210
https://github.com/boot2docker/boot2docker/blob/master/doc/FAQ.md

Docker♡コンテナ

1
2
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
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?