I've created a new wsl instance by following this guideline: https://cloudbytes.dev/snippets/how-to-install-multiple-instances-of-ubuntu-in-wsl2
- Download wsl image: https://cloud-images.ubuntu.com/releases/21.10/release/
- Import to wsl
wsl --import <Distribution Name> <Installation Folder> <Ubuntu WSL2 Image Tarball path>
After that follow the docker installation guideline: https://docs.docker.com/engine/install/ubuntu/
NOTE: wsl does not have systemd, so you cannot start/enable docker via systemctl
I have installed ubuntu-21.10, after starting docker for the first time I got an error:
"Error initializing network controller: error obtaining controller instance ... iptables ... (did not copy the error !!)"
There was additional information about iptables. Found this information which helped a lot:
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
# dockerd, should start fine after switching to iptables-legacy.
sudo service docker start
After aliasing iptables
docker can be started and run successfully!
sudo docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:975f4b14f326b05db86e16de00144f9c12257553bba9484fed41f9b6f2257800
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(amd64)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/