Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can't i attach a container to a docker network?

I've created a user defined attachable overlay swarm network. I can inspect it, but when i attempt to attach a container to it, i get the following error when running on the manager node:

$ docker network connect mrunner baz 
Error response from daemon: network mrunner not found

The network is defined and is attachable

$ docker network inspect mrunner
[
    {
        "Name": "mrunner",
        "Id": "kviwxfejsuyc9476eznb7a8yw",
        "Created": "2019-06-20T21:25:45.271304082Z",
        "Scope": "swarm",
        "Driver": "overlay",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": [
                {
                    "Subnet": "10.0.1.0/24",
                    "Gateway": "10.0.1.1"
                }
            ]
        },
        "Internal": false,
        "Attachable": true,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": null,
        "Options": {
            "com.docker.network.driver.overlay.vxlanid_list": "4098"
        },
        "Labels": null
    }
]


$ docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
4a454d677dea        bridge              bridge              local
95383b47ee94        docker_gwbridge     bridge              local
249684755b51        host                host                local
zgx0nppx33vj        ingress             overlay             swarm
kviwxfejsuyc        mrunner             overlay             swarm
a30a12f8d7cc        none                null                local
uftxcaoz9rzg        taskman_default     overlay             swarm

Why is this network connection failing?

** This was answered here: https://github.com/moby/moby/issues/39391

like image 851
Jack Murphy Avatar asked Mar 16 '26 16:03

Jack Murphy


1 Answers

See this:

To create an overlay network for use with swarm services, use a command like the following:

$ docker network create -d overlay my-overlay

To create an overlay network which can be used by swarm services or standalone containers to communicate with other standalone containers running on other Docker daemons, add the --attachable flag:

$ docker network create -d overlay --attachable my-attachable-overlay

So, by default overlay network cannot be used by standalone containers, if insist on, you need to add --attachable to allow this network be used by standalone containers.

like image 115
atline Avatar answered Mar 18 '26 06:03

atline



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!