Reputation: 31
I have set up Ubuntu 18.04 on my windows using WSL2 and got all the installations for docker-ce and docker-compose done.I verified my installations.
$ sudo service docker start
The above command successfully starts the docker daemons but when I'm trying to build my docker image via below command,
{path that contains yml files}$ docker-compose build
It's failing with the below error.
Service 'comp_app' failed to build: Get https://registry-1.docker.io/v2/: dial tcp: lookup registry-1.docker.io on 172.25.240.1:53: read udp 172.25.254.229:49124->172.25.240.1:53: i/o timeout
I have tried killing all my stopped containers , dangling images . Even restarted my WSL also. None seemed to work.
Upvotes: 2
Views: 6628
Reputation: 303
Under WSL2, you have to use the docker-desktop running on windows, as WSL2 does not support a real init system. To do this:
function install_docker_on_linux_or_wsl2 () {
sudo apt update
sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update
apt-cache policy docker-ce
# Note: on WSL2, this will only install the docker client, as there is no init system
# you need export DOCKER_HOST=tcp://localhost:2375 in your .bashrc or .zshrc file when running on WSL2
# docker desktop must be running, and the option to run unsecure on port 2375 (docker options) must be selected
sudo apt install -y docker-ce
}
After this doing all docker operations e.g. docker images should work.
Upvotes: 2