Why does Docker give error "connect: no route to host" when trying to connect to external resource?

docker

Solution

Try to remove the other bridged network other than the default one and try to pull the image again and it worked for me.

> docker network ls
NETWORK ID          NAME                       DRIVER              SCOPE
b139fe9f89e3        bridge                     bridge              local
e5dfbbee314v        network-1                  bridge              local
6ruvy84eg56n        network-2                  bridge              local
1e0ccbec292a        host                       host                local
e1c69bce4r56        none                       null                local

> docker network rm e5 6r

> docker pull private-repo:port-number/your/image:latest

Problem

When trying to connect to an external resource from a container, I get the following error: ``` [00] app: error: dial tcp {my-ip}:5432: connect: no route to host, try --help ``` I have double-checked all my configs and docker-compose files and rebuilt everything and still, the error persists. (In my case this was a GoLang server in a local container attempting to connect to an aws-hosted PostgreSQL database)

Original source