Skip to content

Instantly share code, notes, and snippets.

@hgross
Created February 19, 2018 17:42
Show Gist options
  • Save hgross/26042d052f58feeb6d1b329e8dd2dfcc to your computer and use it in GitHub Desktop.
Save hgross/26042d052f58feeb6d1b329e8dd2dfcc to your computer and use it in GitHub Desktop.
Change docker_gwbridge subnet address
## Do this on each swarm-node
# store containers attached to the bridge
$ gwbridge_users=$(docker network inspect --format '{{range $key, $val := .Containers}} {{$key}}{{end}}' docker_gwbridge | \
$ xargs -d' ' -I {} -n1 docker ps --format {{.Names}} -f id={})
# stop all containers
# if you have stacks that restart automatically, remove them via docker stack <stackName> rm
$ echo "$gwbridge_users" | xargs docker stop
$ docker network rm docker_gwbridge
$ docker network disconnect -f docker_gwbridge gateway_ingress-sbox
$ docker network rm docker_gwbridge
$ SUBNET=172.20.0.0/20
$ GATEWAY=172.20.0.1
$ docker network create \
--subnet=${SUBNET} \
--gateway ${GATEWAY} \
-o com.docker.network.bridge.enable_icc=false \
-o com.docker.network.bridge.name=docker_gwbridge \
docker_gwbridge
$ echo "$gwbridge_users" | xargs docker start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment