Forked from hgross/gist:26042d052f58feeb6d1b329e8dd2dfcc
Last active
June 23, 2023 14:26
-
-
Save zombig/21e24220cd5d5915cd194946cdc7061b to your computer and use it in GitHub Desktop.
Change docker_gwbridge subnet address
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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 ingress | |
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