CentOS 8.x install podman

From Notes_Wiki

Home > CentOS > CentOS 8.x > Virtualization > podman > Install podman

Enable required repositories to install podman

Install or enable required repositories:

    yum -y install epel-release
    sudo dnf config-manager --set-enabled PowerTools


Install podman and check its version

  • Install podman
    sudo dnf module list | grep container-tools
    sudo dnf install -y @container-tools
  • Check podman version and help
    podman version
    podman --help


Manage podman images

  • Check current images and download required images
    podman images
    podman pull centos
    podman images
  • To delete image syntax is:
    podman rmi <imageid>


Get information about podman

To get information about podman use:

   podman info

This includes location of storage configuration file


Move podman containers to other partition from /var

To move podman containers to other partition from default /var (Often for additional disk space use):

   mkdir /mnt/data1/container-files
   mkdir /mnt/data1/container-files/{var-run-containers,var-lib-containers}
   mv /var/run/containers/* /mnt/data1/container-files/var-run-containers/
   mv /var/lib/containers/* /mnt/data1/container-files/var-lib-containers/
   rmdir /var/run/containers/
   rmdir /var/lib/containers/
   ln -s /mnt/data1/container-files/var-run-containers/ /var/run/containers
   ln -s /mnt/data1/container-files/var-lib-containers/ /var/lib/containers

   #After this validate by using various commands such as
   podman images
   podman run -it centos bash
   df -h  #Inside container 

Refer:


Information about non-root podman containers

Podman has two types of containers rootfull and rootless. Rootfull container information is shown if "podman info" command is run with root privileges. If the same "podman info" command is run as normal user then local user configuration (including storage configuration) is shown.

Same as moving root containers to other partitions, we can move non-root containers of user to other partitions using:

   sudo mkdir /mnt/data1/container-files/home-saurabh-local-share-containers
   sudo chown saurabh:saurabh /mnt/data1/container-files/home-saurabh-local-share-containers
   mv /home/saurabh/.local/share/containers/* /mnt/data1/container-files/home-saurabh-local-share-containers/
   rmdir /home/saurabh/.local/share/containers/
   ln -s /mnt/data1/container-files/home-saurabh-local-share-containers/ /home/saurabh/.local/share/containers


Sharing container images between root and non-root container

Below steps do not work If many images are downloaded using root and same are desired for non-root user then we can do the following to avoid re-downloading the images:

    podman rm -a -f
    podman pod rm -a 
   
    #Should be empty
    podman ps -a  

    #Copy root images to user
    rsync -a --delete  /mnt/data1/container-files/var-lib-containers/storage/  /home/saurabh/.local/share/containers/storage/
    chown -R saurabh:saurabh /home/saurabh/.local/share/containers/storage/
    
    #After this most commands give errors
    podman info
    podman images
    
    #To solve the issue created by copying files use
    rm -rf /home/saurabh/.local/share/containers/*
   
    #Now various commands would start working again
    podman info
    podman images


Home > CentOS > CentOS 8.x > Virtualization > podman > Install podman