Docker Engine on Windows Subsystem for Linux (WSL) 2
January 13, 2022
This article shows how to install Docker Engine on Windows Subsystem for Linux (WSL) 2.
1. Prerequisites
Ubuntu 20.04 distro of Windows Subsystem for Linux (WSL) 2 must be installed. If you are unable to download it from Microsoft Store, download it manually.
2. Install Docker
Install Docker Engine on Ubuntu by following instructions in Docker documentation.
2.2. Set up package repository
Update package index
$ sudo apt-get update
Install packages to allow apt to use a repository over HTTPS:
$ sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
Add Docker’s official GPG key
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Set up the stable package repository
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
2.3. Install Docker Engine
Update package index.
$ sudo apt-get update
Install Docker Engine, Docker CLI and containerd.
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
2.4. Manage Docker as a non-root user
Create docker
group.
$ sudo groupadd docker
Add user to docker
group.
$ sudo usermod -aG docker $USER
Log out and log back in so that your group membership is re-evaluated.
On Linux, you can also run the following command to activate the changes to groups:
$ newgrp docker
2.5. Configure Docker Engine to use HTTP proxy
If your organization uses an HTTP forward proxy, edit /etc/default/docker
file to add relevant environment variables.
Example
export http_proxy="http://proxy.example.com:80"
export https_proxy="https://proxy.example.com:443"
export no_proxy="localhost,127.0.0.1,.example.com"
Remember to replace the values in above example with details of your HTTP proxy. |