Why I need this
I use Podman as my primary container tool, but many of the tools integrate with container work with Docker as default or the only choice, e.g. AWS SAM CLI, act. Due to these tools having great help on productivity, I started to study how to make Podman and Docker work together. Since Docker Desktop is only free for open-source projects, this post aims to install the Docker engine and use Docker CLI to operate Docker.
Pre-condition
This post assumes you already installed Podman and want to install Docker then. Follow the steps below to setup:
- Make sure WSL version is version 2
wsl --set-default-version 2
- Update WSL to the latest
wsl --update
- Choose a OS to host Docker, here we’ll going to use the latest Ubuntu
wsl -t Ubuntu-22.04
- Export the OS, since we’ll going to change the default storage, if you are fine with the default location please jump to the step 7.
wsl --export Ubuntu-22.04 {new path}\Ubuntu-22.04.tar
- Unregist the OS we just installed
wsl --unregister Ubuntu-22.04
- Regist at the new location
wsl --import Ubuntu-22.04 {new path}\Ubuntu-22.04 {new path}\Ubuntu-22.04.tar
- Enter to the OS we just installed
wsl -d Ubuntu-220.4 --user {your_user_name}
- Update the packages
|
|
- Install Docker engine
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Once the install finished, we are almost there, just in case we can check if we can invoke Docker in Ubuntu
sudo docker run hello-world
Docker engine settings
Check the wsl.conf settings in Ubuntu
cat /etc/wsl.conf
Make sure you have the following setting, if no please setup for it.
|
|
We can now successfully operate Docker in Ubuntu but not in Windows (the host OS). To operate Docker via Windows, we need to move forward and add more settings.
sudo mkdir -p /etc/systemd/system/docker.service.d/
sudo vi /etc/systemd/system/docker.service.d/tcp.conf
Add following content:
|
|
The first ExecStart=
is left blank; this is meaningful. It resets ExecStart=
to avoid an error when executing. If you encounter an error message like the one below, please leave this blank in the settings:
docker.service: Service has more than one ExecStart= setting
Restart WSL after you finished.
|
|
Then restart Docker
|
|
Check service’s status
sudo service docker status
Host (Windows) settings
Back to Windows
|
|
We install Docker but no need it run as server
Add new environment variable
|
|
Attention
We use port 2377
rather than default 2375
just because of the Podman use it as default too.