-
Notifications
You must be signed in to change notification settings - Fork 1
Installing Docker on Ubuntu WSL
Installing and running applications within the Windows Windows Subsystem for Linux will greatly improve performance of file system operations.
-
Open the Ubuntu terminal by searching for "Ubuntu" in the Start menu.
-
Update the apt package list by running the following command:
sudo apt-get update
-
Install the necessary packages by running the following command:
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
-
Add the Docker GPG key by running the following commands:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/docker.gpg
-
Add the Docker repository to your apt sources list by running the following command:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
-
Update the apt package list again by running the following command:
sudo apt-get update
-
Install Docker by running the following command:
sudo apt-get install docker-ce docker-ce-cli containerd.io
-
Enable legacy iptables (docker won't work with iptables-nft).
sudo update-alternatives --config iptables
enter 1 to select iptables-legacy.
-
Start the Docker service by running the following commands:
sudo service docker start
-
Verify that Docker is running by running the following command:
sudo docker run hello-world
This command should download and run a Docker container and output a "Hello from Docker!" message.
To run docker without having to use sudo, you can create a docker group and add yourself to that group.
sudo groupadd docker
sudo usermod -aG docker $USER
Once you've this log out, and then connect to wsl again. Try running the hello-world example without using sudo.
docker run hello-world