How to migrate podman workloads from one user to another ?

Solution Verified - Updated -

Environment

  • Red Hat Enterprise Linux 7
  • Red Hat Enterprise Linux 8
  • Red Hat Enterprise Linux 9
  • podman

Resolution

  • There is as such no direct way of migrating the images and containers from one user to another. Following steps can be followed to move the containers and images from one user to another.

    Note: Let us assume the initial user to be user1 and the user the workloads to be migrated to as user2

  • Backup the containers and images of user1 as tar balls using podman export and podman save.

[user1@vm250-219 ~]$ podman export -o /tmp/container.tar <container-id> 
[user1@vm250-219 ~]$ ls -l /tmp/container.tar 
-rw-r--r--. 1 user1 user1 214818304 Aug 22 04:07 /tmp/container.tar
[user1@vm250-219 ~]$ podman save -o /tmp/image.tar <image-id>
Copying blob 815ca85c5fa5 done  
Copying config 7e569fa199 done  
Writing manifest to image destination
Storing signatures
[user1@vm250-219 ~]$ ls -l /tmp/image.tar
-rw-r--r--. 1 user1 user1 214832640 Aug 22 04:08 /tmp/image.tar
  • Assign permissions using to this files so that user2 user can extract the tar files.
  • Stop and remove the existing containers of user1 using podman stop and podman remove.
  • Switch to user2 and use this tarball to generate the images using podman load and podman import.
[user2@vm250-219 tmp]$ podman load -i image.tar 
Getting image source signatures
Copying blob 815ca85c5fa5 done  
Copying config 7e569fa199 done  
Writing manifest to image destination
Storing signatures
Loaded image(s): sha256:7e569fa199c00a48fc249200463d903ca157a4e965348a845827871f4ede3714
[user2@vm250-219 tmp]$ podman images
REPOSITORY  TAG         IMAGE ID      CREATED      SIZE
<none>      <none>      7e569fa199c0  2 weeks ago  215 MB
[user2@vm250-219 tmp]$ podman import container.tar 
Getting image source signatures
Copying blob 5d51d87fe0ff done  
Copying config 9241c25300 done  
Writing manifest to image destination
Storing signatures
sha256:9241c25300310e2668c1afa9e943374edf4a2eae36b4a4186bebe889e4f57d9a
[user2@vm250-219 tmp]$ podman images
REPOSITORY  TAG         IMAGE ID      CREATED      SIZE
<none>      <none>      9241c2530031  2 hours ago  215 MB
  • This will generate the images and the containers can now be created.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments