1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Docker buildしてからNo route to hostになった際の解決方法

1
Posted at

起きた事象

  • 環境: WSL2 Ubuntu 22.04
  • Dockerビルド後にネットワークに繋がらなくなり,No Route to Hostになってしまった。
    curl ipinfo.io
    curl: (7) Failed connect to xxx:xxx.xxx.xxx:yy; No route to host
    

原因

これと同じ事象が起きていた。
インターネットに出るために通過が必要なプロキシのIPとDockerが作成したネットワークの範囲がかぶってしまっていた。
↓イメージ

  • proxyのip: 172.20.77.77
  • Docker network: 172.20.0.0/16

暫定解決策

該当のDocker networkを探して削除する

docker network ls
docker network inspect xxxxxxx # NETWORK IDを指定
docker network rm xxxxxxx

再発防止策

/etc/docker/daemon.jsondocker networkが作成するipの範囲を指定して172.20.0.0/16が使われないようにしてみた。
しばらくこれを試して問題が発生しないか試す。

{
  "default-address-pools": [
    {
      "base": "172.19.0.0/16",
      "size": 24
    },
    {
      "base": "192.168.0.0/16",
      "size": 24
    }
  ]
}

sudo systemctl restart docker
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?