visit
The below paragraphs are about the issues I found on Debian and Ubuntu. So, why we need OpenSUSE Tumbleweed as Linux distribution. For this reason, I summarised in the Conclusion paragraph only the needed steps.
$ sudo apt update
$ sudo apt upgrade
$ sudo apt install podman docker-compose
Then I configured podman to avoid using systemd. On WSL2 we cannot rely on it because the init system is a custom Microsoft solution.
To do this I copied /usr/share/containers/containers.conf
to $HOME/.config/containers
. Then I changed the latter. Specifically, I set cgroup_manager
to cgroupfs
and events_logger
to file
:
...
[engine]
...
cgroup_manager = "cgroupfs"
...
events_logger = "file"
...
I found this tips on .
Then I tried to run a simple container:
$ docker run -dp 8080:80 docker.io/httpd
But I got: Error: Error initialising source docker … x509: certificate signed by unkown authority
. To resolve this issue I installed ca-certificates
. Then I tried to run the container again:
$ sudo apt install ca-certificates
$ docker-run -dp 8080:80 docker.io/httpd
This time it worked! And the host can reach the container.
So, I tried a simple docker-compose to test the communication between two containers:
version: "3.7"
services:
db:
image: docker.io/mariadb
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
phpmyadmin:
image: docker.io/phpmyadmin
restart: always
ports:
- 8080:80
environment:
- PMA_ARBITRARY=1
But I got this error:
$ docker-compose up
ERROR: Couldn't connect to Docker daemon at http+docker://localhost - is it running?
If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
Obviously it’s not running. So, I checked the podman documentation and we need to start the podman socket manually. We should do it manually because we cannot rely on a systemd service. Then we should indicated the socket location to docker-compose.
$ podman system service --time=0 unix:///home/user/podman.sock &
[1] <a number>
$ docker-compose -H unix:///home/user/podman.sock up
Pulling images...
Creating images...
ERROR: for <service name> network connect is not enabled for rootless containers
ERROR: for <service name> network connect is not enabled for rootless containers
I searched the error and I found a GitHub about podman. It seems this is a bug fixed in the version 3.2.
So, I searched other supported Linux distributions in the hope to find a newer podman version.
$ sudo zypper update
$ sudo zypper install podman docker-compose
At this point I configured podman to not use systemd, as Debian.
I tried to run a simple container exposing a port. And it worked.
So, I started the podman socket. Then I launched docker-compose with the same file. And the two containers started!
But, when I tried to connect to the database from phpmyadmin I received the following error:
getaddrinfo failed: Name or service not known
I investigated a bit and I found that containers were unable to communicate through DNS name.
For this reason I researched about networking in Podman 4.x and I found that they changed the network stack. But it should also supports DNS resolution.
Yet, podman continues to support the old network stack (i.e. cni
) for compatibility reason. So, I checked what’s the enabled stack and it was the old one. So, I research about it and DNS resolution and I found an . The old stack supports plugins and one of them regards DNS name resolution: dnsname
.
$ sudo zypper install cni-plugin-dnsname
And this time the containers communicated correctly.
Furthermore, I forced the old stack in podman adding to $HOME/.config/containers/containers.conf
:
...
[network]
network_backedn = "cni"
...
Temporary failure resolving ‘<a domain name>’
W: Failed to fetch <a URL>
Error message: Could not resolve host: <a host name>'
So, I read the /etc/resolv.conf
file and there was a bad DNS server. Fortunately Microsoft added a hint:
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver <BAD_NAMESERVER>
So, I wrote the /etc/wsl.conf
file:
[network]
generateResolvConf = false
Then, I removed the /etc/resolv.conf
file (it was a link) and I created the correct one:
nameserver <GOOD_NAMESERVER_IP>