TimSO
TimSO

Reputation: 70

Use docker containers with podman

Is is possible to use existing docker containers with podman?

I am using regular rooted docker and have images and containers. Now I would like to test rootless podman with those same containers, but it does not see them. This is local test, so security is not a factor. User is sudo. It is Linux Mint/Ubuntu.

Upvotes: 1

Views: 5945

Answers (1)

larsks
larsks

Reputation: 312138

You cannot use podman to interact with docker containers.

You can export images from docker, load those images with podman, and then use them to create podman containers.

While you can use docker save and podman load to accomplish this task, it is perhaps more convenient to use skopeo, which allows you to perform the same thing in a single command:

skopeo copy docker-daemon:myimage:mytag containers-storage:myimage:mytag

For example, if I have:

$ docker image ls | grep traefik
traefik                               v2.11     c1ef9171e9d1   4 weeks ago     159MB
traefik/whoami                        latest    9807740ea1ff   9 months ago    6.61MB

Then I can copy the traefik/whoami:latest image from docker to podman like this:

skopeo copy docker-daemon:traefik/whoami:latest containers-storage:traefik/whoami:latest

And then start a container using that image:

podman run --rm -d -p 8080:80 traefik/whoami:latest

If you actually want to "migrate" a running container, it may be more appropriate to use docker export to export a container filesystem to a tar file, and then use podman import to create a new container image from that tar file (and then podman run to start a container from that image):

docker export my-running-container | podman import - my-image
podman run ... my-image

Upvotes: 2

Related Questions