Quantcast
Channel: Active questions tagged windows-subsystem-for-linux - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2930

How to fix networks conflict between WSL and Docker compose?

$
0
0

Few days ago, on WSL2 (Ubuntu 20.04), I installed docker compose and created a docker-compose.yml that builds a database based on postgres:12 image. The first time I ran it, everything worked fine.

A few days later, when I ran my docker compose again, the build didn't work. Docker cannot access to internet to pull the postgres image, the connection is refused. Here is what it said :

$ docker compose up -d[+] Running 1/0 ! database Warning                                                                                                                              [+] Building 0.0s (3/3) FINISHED => [internal] load build definition from Dockerfile                                                                                                 => => transferring dockerfile: 290B                                                                                                                 => [internal] load .dockerignore                                                                                                                    => => transferring context: 2B                                                                                                                      => ERROR [internal] load metadata for docker.io/library/postgres:12-alpine                                                                         ------> [internal] load metadata for docker.io/library/postgres:12-alpine:------failed to solve: postgres:12-alpine: failed to do request: Head "https://registry-1.docker.io/v2/library/postgres/manifests/12-alpine": dial tcp: lookup registry-1.docker.io on 172.18.0.1:53: read udp 172.18.0.1:51217->172.18.0.1:53: read: connection refused

So I checked if I still had an Internet access in WSL by trying sudo apt-get update or ping google.com and I didn't...The fact is I just don't have any internet access anymore in WSL since that day.

$ ping www.google.comping: www.google.com: Temporary failure in name resolution

What I have tried :

  • I tried to go into /etc/resolve.conf and modify nameserver address by enter google DNS, 8.8.8.8, instead of the default address. resolve.conf content :
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:# [network]# generateR.esolvConf = falsenameserver 8.8.8.8

I have even created a wsl.conf to keep the nameserver 8.8.8.8. After that, my problem was fixed for a few minutes but it all crashes again.

  • The docker error is not the same if I change nameserver in resolve.conf. With default nameserver, if I want to pull postgres image in docker, I have a connection refused (like with docker compose) :
$ docker pull postgresUsing default tag: latestError response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on 172.18.0.1:53: read udp 172.18.0.1:57439->172.18.0.1:53: read: connection refused

And with nameserver 8.8.8.8, I have a timeout error from docker :

$ docker pull postgresUsing default tag: latestError response from daemon: Get "https://registry-1.docker.io/v2/": dial tcp: lookup registry-1.docker.io on 8.8.8.8:53: read udp 172.18.7.177:46999->8.8.8.8:53: i/o timeout
  • Strange thing though, if I reboot my PC and then run WSL, I have an ephemere internet connection, around 2mins, (if i do a sudo apt-get update, it works), and it finally loses any connection then.

I think docker or docker compose must have created conflict in my WSL networks, maybe an IP address already used by something else, but I can't explain how. Here is my Docker and Docker compose version.

Docker version 23.0.3, build 3e7cbfdDocker Compose version v2.17.2

Thanks for your help, I honestly don't know what to do.


Viewing all articles
Browse latest Browse all 2930

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>