Migrating from Docker to Podman: A Step-by-Step Guide

Migrating from Docker to Podman: A Step-by-Step Guide




How to migrate volumes

Get the path of each volume from Docker

#List all your volumes
docker volume ls

#For each volume
docker volume inspect my_volume

#Then keep the Mountpoint path 
"Mountpoint": "/var/lib/docker/volumes/mon_volume/_data"

Enter fullscreen mode

Exit fullscreen mode

Recreate your volume in Podman

podman volume create my_volume
# Get the path volume
podman volume inspect mon_volume_podman
# Example 
"Mountpoint": "/home/dev/.local/share/containers/storage/volumes/mon_volume_podman/_data"
Enter fullscreen mode

Exit fullscreen mode

Then copy your docker volume to the podman volume

#The /. at the end is important, keep it
sudo cp -a /var/lib/docker/volumes/my_volume/_data/. /home/dev/.local/share/containers/storage/volumes/my_volume_podman/_data/
Enter fullscreen mode

Exit fullscreen mode



How to migrate images

I recommend to push your image in a registry, but if you want transfert it manually, you can do this :

#List your images
docker images
#Then to export your image
docker save -o my_image.tar my_image:latest
#To import into podman 
podman load -i my_image.tar
#Check your image is imported
podman images
Enter fullscreen mode

Exit fullscreen mode



How to migrate containers

You can reproduce the command run with podman, nether less you need to transfert the volumes.
You can list all the volumes used with this command

docker inspect my_app | grep Mounts -A 20
Enter fullscreen mode

Exit fullscreen mode

You can also create a snapshot, a image from you container, like this

docker commit my_app my_app_image
docker save -o my_app_image.tar my_app_image
Enter fullscreen mode

Exit fullscreen mode



Remove Docker

sudo apt purge docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
sudo rm -rf /var/lib/docker
Enter fullscreen mode

Exit fullscreen mode



Create an alias Docker for Podman

echo "alias docker=podman" >> ~/.bashrc
source ~/.bashrc
Enter fullscreen mode

Exit fullscreen mode



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *