Score:0

Docker remove not existing container from `host` network

in flag

I cannot start one of my containers because there is an old version of the container stuck in the network.

When i try to start the container (with docker-compose) docker-compose up -d service_name i get the following error:

Creating project_service_name_1 ... error

ERROR: for project_service_name_1  Cannot start service service_name: endpoint with name project_service_name_1 already exists in network host

ERROR: for service_name  Cannot start service service_name: endpoint with name project_service_name_1 already exists in network host
ERROR: Encountered errors while bringing up the project.

When i inspect the host network i get the info that there is a container connected to the network docker network inspect host:

[
    {
        "Name": "host",
        "Id": "...",
        "Created": "2020-10-19T10:59:34.995303624+02:00",
        "Scope": "local",
        "Driver": "host",
        "EnableIPv6": false,
        "IPAM": {
            "Driver": "default",
            "Options": null,
            "Config": []
        },
        "Internal": false,
        "Attachable": false,
        "Ingress": false,
        "ConfigFrom": {
            "Network": ""
        },
        "ConfigOnly": false,
        "Containers": {
            "38d0a72cdb7d454082e2d41f092b5087e7f22cd192eea48ba70afffb5e7ca476": {
                "Name": "project_service_name_1",
                "EndpointID": "26d6e12b6983b57527cae6445d30ba35bf7aa9038b7b7877842c4d2ee961079e",
                "MacAddress": "",
                "IPv4Address": "",
                "IPv6Address": ""
            },
            ...
        },
        "Options": {},
        "Labels": {}
    }
]

docker network disconnect host project_service_name_1 returns 0 (success) the first time but does not remove project_service_name_1 from the host network. the second time i get:

Error response from daemon: container 4bf82e4d1dfcf469e996aa412bfbd9bb52a2729dcd5cdc1dfa49d01ee25a213a is not connected to the network host

so i guess it removed 4bf82e4d1dfcf469e996aa412bfbd9bb52a2729dcd5cdc1dfa49d01ee25a213a instead of 38d0a72cdb7d454082e2d41f092b5087e7f22cd192eea48ba70afffb5e7ca476 from the network (although 4bf82e4d1dfcf469e996aa412bfbd9bb52a2729dcd5cdc1dfa49d01ee25a213a was not showing up in host network before)

disconnecting the old id of the container does not work as it's no longer existing docker network disconnect host 38d0a72cdb7d454082e2d41f092b5087e7f22cd192eea48ba70afffb5e7ca476:

Error response from daemon: No such container: 38d0a72cdb7d454082e2d41f092b5087e7f22cd192eea48ba70afffb5e7ca476

I also cannot recreate the host network as it's pre-defined docker network rm host:

Error response from daemon: host is a pre-defined network and cannot be removed

How do i get rid of the reminiscence of the container in the network?

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.