1. How to install wsl2 docker¶
1.1 Resource¶
- Microsoft Official Website - WSL install
- Microsoft Official Website - Basic CLI
- Install Docker on WSL
1.2 WSL install¶
Just follow the Microsoft tutorial (link above):
- Verify that your PC runs with Windows 10/11 and up to date (Windows 10 versions 2004 and more (build 19041 and more) or Windows 11.)
- Prefer recommended Linux distribution : Ubuntu (without version number behind)
- When install is finished, open a Powershell window and do:
If WSL version is 1, do:
If WSL version 2 and linux kernel version are given you are ready to install Docker.
1.3 Docker install¶
Prerequisites
- WSL2
- Linux distro (the user defined at installation is a root one).
You can follow the tutorial (link above) or if you have installed Ubuntu execute commands listed below, (simplified version from the Bowman tutorial).
In the context of the AeroWebb project, Docker allows the execution of unit tests that perform operations on the database, by simulating this database.
1.3.1 Enable Systemd¶
By default, Systemd is disabled in your distro in WSL, so in order to enable it you'll have to do the following :
- open your
/etc/wsl.conffile with your favourite text editor (here it's vi)sudo vi /etc/wsl.conf - add the following block
- save and quit (for vi press Escape and type
:xthen press Enter, for nano it'sctrl+x) - shutdown your wsl session in powershell
wsl --shutdown - relaunch a new WSL session
- for checking that Systemd is now up you just have to enter the following command
systemctllist-unit-files --type=service - You should see a list of all services installed in Linux. Next, press
qto quit
1.3.2 Update/upgrade packages¶
As we use no proxy, no network connectivity problem should arise during update.
1.3.3 Prepare for Docker installation: remove residue¶
1.3.4 Prepare for Docker installation: install dependencies¶
1.3.5 Debian/Ubuntu package repository configuration¶
First temporarily set some OS-specific variables:
Then, make sure that apt will trust the repo:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo tee /etc/apt/trusted.gpg.d/docker.asc
Then add and update the repo information so that apt will use it in the future:
echo "deb [arch=amd64] https://download.docker.com/linux/ubuntu ${VERSION_CODENAME} stable" | sudo tee /etc/apt/sources.list.d/docker.list
1.3.6 Install Docker¶
Now we can install the official Docker Engine and client tools:
1.3.7 Add user to docker group¶
Now we can install the official Docker Engine and client tools:
Then close that WSL window, and launch WSL again. You should see docker when you run the command groups to list group memberships.
1.3.8 Launch Docker¶
To launch Docker, you'll only need Systemd, use the following command in order to do it :
To test it, you will have to test the following commands :
If the pull is successful you're done with basic configuration! Now you can work directly on WSL with docker. If some of your docker instances need to work with 2 MoRO network, some further configuration is needed, check below.
1.4 WSL2, Docker and 2MoRO¶
To be able to pull artefacts from Nexus, Docker must have access.
Create required files (as root)
Edit (press i) and fill daemon.json (press Escape then type :x to save file / press Escape then type :q! to exit without saving)
with following JSON
Edit (press i) and fill config.json (press Escape then type :x to save file / press Escape then type :q! to exit without saving)
with following JSON
Restart the docker service :
Now you can pull from 2MoRO Nexus! And you're all done!
1.5 Add Portainer in my docker¶
If you want to still have a GUI for your Docker like you had with Docker Desktop, then Portainer will be your future best friend.
First enter this in your WSL
docker run -d -p 8111:8000 -p 9113:9443 --name portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \
portainer/portainer-ce:latest
Note
Here, the default Portainer ports 8000 and 9443 are remapped to 8111 and 9113 respectively to avoid any conflict with other (default) ports from other tools.
Then, once your Docker with Portainer is installed and launched, go to this URL https://localhost:9113/, then you just have to create your login and password for Portainer, and it's all good.
1.6 Troubleshooting¶
1.6.1 If you get an IPTables error when launching dockerd, do the following¶
Then select iptables-legacy instead of iptables-nft, it should work fine after this.
1.6.2 To allow docker pull from default WSL profile¶
Restart WSL then run the following command:
1.6.3 To start Docker automatically at WSL startup¶
Once you have installed Docker and enabled systemd, you'll just have to do the following command
It will start automatically Docker when you start your session, and also you will be able to check that Docker is up with this command
Created: 2024-01-30