5.11 Managing and Configuring Containers with Podman

5.11 Managing and Configuring Containers with Podman

Introduction:

Podman, Skopeo, and Buildah have emerged as lightweight alternatives to Docker, offering improved security, lower resource requirements, and native integration with systemd. This guide provides an overview of Podman and demonstrates how to manage and configure containers using Podman commands.

Installing Podman: To install Podman, follow these steps:

# Install Podman
sudo dnf install podman

# Configure container registries
sudo vi /etc/containers/registries.conf

# Disable Docker CLI emulation message
sudo touch /etc/containers/nodocker

Podman Commands Overview: Podman offers a rich set of commands for managing containers. Here is an overview of commonly used Podman commands:

CommandDescription
attachAttach to a running container
buildBuild an image using Containerfile instructions
commitCreate a new image from a changed container
createCreate, but do not start, a container
diffInspect changes on a container's filesystem
execRun a process in a running container
exportExport a container's filesystem contents as a tar archive
help (or h)Show a list of commands or help for one command
historyShow history of a specified image
imagesList images in local storage
importImport a tarball to create a filesystem image
infoDisplay system information
inspectDisplay the configuration of a container or image
killSend a specific signal to one or more running containers
loadLoad an image from an archive
loginLogin to a container registry
logoutLogout of a container registry
logsFetch the logs of a container
mountMount a working container’s root filesystem
pausePauses all the processes in one or more containers
psList containers
portList port mappings or a specific mapping for the container
pullPull an image from a registry
pushPush an image to a specified destination
restartRestart one or more containers
rmRemove one or more containers from the host
rmiRemoves one or more images from local storage
runRun a command in a new container
saveSave an image to an archive
searchSearch registry for an image
startStart one or more containers
statsDisplay resource usage statistics for one or more containers
stopStop one or more containers
tagAdd an additional name to a local image
topDisplay the running processes of a container
umount (or unmount)Unmount a working container’s root filesystem
unpauseUnpause the processes in one or more containers
versionDisplay Podman version information
waitBlock on one or more containers

Understanding Docker Commands: docker run vs docker start

Docker is a widely used platform for developing, shipping, and running applications inside containers. Two essential commands in Docker are docker run and docker start. While both commands are used to manage containers, they serve different purposes. This guide provides an overview of these commands and demonstrates their usage.

Installing Docker: To install Docker, follow these steps:

# Install Docker
sudo dnf install docker

# Configure container registries
sudo vi /etc/containers/registries.conf

# Disable Docker CLI emulation message
sudo touch /etc/containers/nodocker

Using Docker Commands:

  1. Search and Pull Images:

    • Search for an image:

        docker search nginx
      
    • Pull an image from the registry:

        docker pull docker.io/library/nginx
      
  2. Viewing and Managing Images:

    • View images in the local storage:

        docker images
      
    • Delete an image:

        docker rmi nginx
      
  3. Creating and Managing Containers:

    • Create and start a new container:

        docker run -d nginx
      
    • List running containers:

        docker ps
      

      or

        docker container list
      
    • Stop a container:

        docker stop nginx
      
    • View all containers (including stopped ones):

        docker ps --all
      
    • Delete a container:

        docker rm --force nginx
      
  4. Connecting to Containers:

    • Connect to a container and give it a specific name:

        docker run -d -p 8080:80 --name mywebserver nginx
      

Conclusion:

Podman, Skopeo, and Buildah offer a lightweight and secure alternative to Docker for managing containers. With features such as rootless mode, native systemd integration, and reduced resource requirements, Podman is well-suited for containerized environments. By mastering Podman commands, users can efficiently build, manage, and deploy containers while benefiting from enhanced security and flexibility.

In summary, docker run is used to create and start a new container based on an image, while docker start is used to start a pre-existing container that has been stopped. By understanding the differences between these commands and their respective use cases, Docker users can effectively manage containers and streamline their development and deployment processes.

Did you find this article valuable?

Support Vijay Kumar Singh by becoming a sponsor. Any amount is appreciated!