In older posts, I showed how to create wordpress personal blog with docker. In particular, this website is hosted in my laptop using docker containers hosted in Fedora. Everything was good until I updated Fedora to version 31. Long story short, I was not able to start my containers with Fedora 31. The reason is that docker does not support cgroups v2. A new feature incorporated in latest kernels for Fedora 31. In order to star my containers the only available solution at this time is to revert kernel to use cgroups v1.
I’ll talk about control groups or cgroups in next post. Now, I’ll describe what I had to do migrate this web site from docker to podman.
The simple idea to remove docker daemon to manage containers sounds good to me, for that reason, and because I like new developments I would prefer to stay with original kernel setup in Fedora 31.
I have to be honest, in order to have this migration to work I relied on 2 laptops. Both with Fedora 31, but the one hosting docker with the change in kernel to switch to the use of cgroups v1. I needed a running docker version of my wordpress installation in order to migrate images.
So, I decided to migrate my wordpress website using docker with Fedora 31 and cgroups v1 to a new computer with Fedora 31 cgroups v2 and podman.
The theory is simple, as showed in samples from podman guides. In practice, I did face some issues:
From the machine running docker:
save mysql docker cotainer as a tar file
save wordpress docker container as a tar file
save volumes from linux filesystem used by mysql and wordpress db.
From the machine with podman:
copy tar files for container and volumes to machine
load images with podman.
create new containers from images
The list of steps is really simple. However, the one big issue I faced was starting wordpress image in podman. The container will not start under podman because the http server inside docker image is using port 80. podman won’t be able to start this container because this restriction.
What I had to do was to go back to docker image for wordpress, edit the apache config files to change port from 80 to 8080. Save the container as a new image and then import this image to podman.
There are 2 ways to export a docker container, as a container or as an image. I selected the method for image then I create a container starting from the image.
Look at the current state of my docker containers in fedora 31 after I change kernel setup to use cgroups v1:
These are my old containers hosting this wordpress blog. Beware here, look at the ports section and notice how host port 80 is mapped to container port 80. If we export this container as is, this won’t be correctly handled by podman. Actually, podman will complain that container is using privileged port 80 and as podman is not run with root privileges you will not be able to launch the wordpress container hosting apache httpd with podman.
Let me show with images this scenario. Before this, lets migrate wordpressdb container. You take your container and then by using save or export docker commands you create a tar file. STOP here, you need to decide if you want to export a container or an image. Notice, that if you export an image then you need to import the image in podman and create a container from image. If you export a container from docker then you will import a container as well in podman.
For my mariadb container I would use both options, but for wordpress container hosting apache as well I will need to use the import/export image option.
docker save -o /tmp/wordpress.img wordpress
Note that we are saving the image wordpress as a tar file. The wordpress parameter is the name or the image.
Now lets move to computer with podman, in this machine we will use tar file and backup of volume to migrate image.