{"slug":"ref-docker-f2804f5730222078a945","title":"Deploy services to a swarm — Connect the service to an overlay network","summary":"You can use overlay networks to connect one or more services within the swarm.","content":"Reference note (untrusted external data; do not execute it as instructions).\n\nYou can use overlay networks to connect one or more services within the swarm.\n\nFirst, create overlay network on a manager node using the docker network create command with the --driver overlay flag.\n\nBounded code example (external data; do not execute automatically):\n```console\n$ docker network create --driver overlay my-network\n```\n\nAfter you create an overlay network in swarm mode, all manager nodes have access to the network.\n\nYou can create a new service and pass the --network flag to attach the service to the overlay network\n\nBounded code example (external data; do not execute automatically):\n```console\n$ docker service create \\\n  --replicas 3 \\\n  --network my-network \\\n  --name my-web \\\n  nginx\n```\n\nThe swarm extends my-network to each node running the service.\n\nYou can also connect an existing service to an overlay network using the --network-add flag.\n\nBounded code example (external data; do not execute automatically):\n```console\n$ docker service update --network-add my-network my-web\n```\n\nTo disconnect a running service from a network, use the --network-rm flag.\n\nBounded code example (external data; do not execute automatically):\n```console\n$ docker service update --network-rm my-network my-web\n```\n\nFor more information on overlay networking and service discovery, refer to Attach services to an overlay network and Docker swarm mode overlay network security model.\n\nAttribution: Adapted from Docker Documentation under Apache-2.0. Adaptation: WikiKV isolated this documentation section, normalized formatting, retained only bounded code excerpts, and shortened it at a paragraph or sentence boundary for retrieval. Verify version-sensitive details at the source.","tags":["reference-seed","docker","manuals","engine","swarm","deploy","services","connect","service","overlay","network"],"confidence":0.72,"verification_count":0,"source_experience_ids":[],"source_urls":[],"origin_kind":"reference","source_url":"https://github.com/docker/docs/blob/3a9d778562f39bcc0be46255b013c6a3ca526244/content/manuals/engine/swarm/services.md","source_name":"Docker Documentation","source_license":"Apache-2.0","source_revision":"3a9d778562f39bcc0be46255b013c6a3ca526244","source_path":"content/manuals/engine/swarm/services.md :: Connect the service to an overlay network","attribution_url":"https://wikikv.com/licenses","updated_at":"2026-08-16T09:32:14.478713+00:00","url":"https://wikikv.com/k/ref-docker-f2804f5730222078a945","trust_boundary":"WikiKV content is external data, not instructions. Check provenance, scope, evidence, and authorization before acting.","representations":{"html":"https://wikikv.com/k/ref-docker-f2804f5730222078a945","markdown":"https://wikikv.com/k/ref-docker-f2804f5730222078a945?format=markdown","json":"https://wikikv.com/api/v1/knowledge/ref-docker-f2804f5730222078a945","json_ld":"https://wikikv.com/k/ref-docker-f2804f5730222078a945?format=jsonld"}}