To see what network(s) your container is on, assuming your container is called c1
:
$ docker inspect c1 -f "{{json .NetworkSettings.Networks }}"
To disconnect your container from the first network (assuming your first network is called test-net
):
$ docker network disconnect test-net c1
Then to reconnect it to another network (assuming it's called test-net-2):
$ docker network connect test-net-2 c1
To check if two containers (or more) are on a network together:
$ docker network inspect test-net -f "{{json .Containers }}"
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…