How to Move Containers From Docker to Podman

First, let's commit our container:


Then save it as an archive with:

docker save NEW_NAME | gzip > NEW_NAME.tar.gz

Let's load the image into Podman with:

gunzip -c | podman load

We can now run the image in Podman:

podman run -d --name=ANY_NAME --publish port:port NEW_NAME

  • -d: for daemon
  • --name: to name the container
  • --publish: expose / map ports
  • NEW_NAME: the source image we imported

But wait. For copying things like databases we will need a little more setup.

Mongo issues?

We need to create a network for things such as mongo and mongo-express to communicate within Podman. To do so we can do:

podman network create mongo-net

Then when creating the containers we can reference this network for the containers with the --network option.

Need to import DB data?

We can make use of mongodump to accomplish this. For this, we'll need the original instance of Mongo running in Docker. Let's first create a temporary dump locally in the container by using:

docker exec mongo bash -c 'mongodump --db DB_NAME --gzip --archive=/tmp/DUMP_NAME.dump'

We need to now copy the archived dump to our local file system. To accomplish this let's do:

docker cp mongo:/tmp/DUMP_NAME.dump ./

We've extracted our data to be outside the container. Let's put it in the new one now with:

podman cp DUMP_NAME.dump MONGO_INSTANCE:/tmp/DUMP_NAME.dump

And finally, we can restart our database data with:

podman exec mongo bash -c 'mongorestore --db DB_NAME --gzip --archive=/tmp/DUMP_NAME.dump'

And now using something like NoSQLBooster and refreshing the connection we should see all our original data in the database.

I Keep Typing the Wrong Command

Just make an alias in your ~/.zshrc (or whatever shell you're using) with the line

alias docker=podman

Save the line, close all terminal instances, re-open a new terminal, and now the docker command will be mapped to Podman.


Some of these commands could be condensed. For instance, the creation of the dump archive and copying it to the local machine could be condensed but I itemized them to make the steps easier to follow.