Stefan Lippeck
Stefan Lippeck

Reputation: 455

I need to remove a deleted network from a docker container

I'm working with docker on a local machine (all windows). To allow my containers to access other resources in my Network, i created a new network and gave it the needed routing/gateway info.

After restarting my machine to install a VPN (unrelated to my docker containers) the network was gone and all the containers connected to that network refuse to start with this error:

DockerDo : Error response from daemon: network 0935c770e7e107c64e3255eaa56de2d2fce90aab108682196d4e2960a2fe5726 not found

Is there any way to disconnect the network "post reboot" from the container? or recreate the network with that ID would be fine two.

edit: i already tired using the disconnect command. either the ID is not translated or i don't know what is should tell docker to disconnect. This is copied right from my PS-console:

C:\WINDOWS\system32> docker network ls
NETWORK ID          NAME                DRIVER              SCOPE
4661e7886520        nat                 nat                 local
bad4235f0598        none                null                local
C:\WINDOWS\system32> docker start BACH-dev
Error response from daemon: network 0935c770e7e107c64e3255eaa56de2d2fce90aab108682196d4e2960a2fe5726 not found
Error: failed to start containers: BACH-dev
C:\WINDOWS\system32> docker network disconnect 0935c770e7e107c64e3255eaa56de2d2fce90aab108682196d4e2960a2fe5726 BACH-dev
Error response from daemon: container 24bfd23804c7a95a923d0626c41f4c949317cb34a45cb81bc430dc2fa96037ae is not connected to the network 0935c770e7e107c64e3255eaa56de2d2fce90aab108682196d4e2960a2fe5726

Upvotes: 2

Views: 5919

Answers (3)

Arwyn
Arwyn

Reputation: 151

I know its an old question, but this is all google comes up with, so I'm leaving my solution for posterity.

You can use the "network name" instead of the "Network ID" with docker network disconnect <network-name>. You can get the network name with docker inspect <container-id>.

If you still get a similar error, create a new network with the same name with docker network create <network-name> and try again. In my case a network with the same name (different id) already existed, so I didn't need this step.

Upvotes: 1

Zeitounator
Zeitounator

Reputation: 44615

One possible option to try to recover your data from the container (I'm not 100% sure it can work in your specific case...).

  1. Create an image from the stopped container state
    docker commit my_stopped_container my_recovery_img:latest
    
  2. Delete the current container
    docker rm my_stopped_container
    
  3. Recreate the container from the dumped image
    docker run [your_options] --name my_stopped_container my_recovery_img:latest [your command]
    

Meanwhile, you should make sure you don't get in this situation again by securing your critical data on a volume or a bind mount.

Upvotes: 1

Fritz Duchardt
Fritz Duchardt

Reputation: 11870

# connect to new network   
docker network connect new-network-name container-name

# disconnect from old network
docker network disconnect old-network-name container-name

Upvotes: 0

Related Questions