Using composer
Since composer v3.2 it is possible to configure the attachable property through the composer file using the keyword attachable
like:
networks:
mynet1:
driver: overlay
attachable: true
Using docker network create
Since Docker Engine API v1.25 it is possible to create a network and make it attachable using the --attachable
parameter like:
docker network create --driver overlay --attachable my-overlay-network
To update an already running docker service:
-
Create an attachable overlay network:
docker network create --driver overlay --attachable my-attachable-overlay-network
-
Remove the network stack with a disabled “attachable” overlay network (in this example called:
my-non-attachable-overlay-network
):docker service update --network-rm my-non-attachable-overlay-network myservice
-
Add the network stack with an enabled “attachable” overlay network:
docker service update --network-add my-attachable-overlay-network myservice