Open In App

How to Monitor Containers with the Podman "ps" Command

Last Updated : 17 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In the realm of containerization, where applications are bundled into units, for deployment it's crucial to have insight into the operational status of these containers. The Podman 'ps command provides a perspective, on this landscape enabling you to oversee and control your active containers.

Terminologies

  • Podman: Podman is a user container engine that operates without a daemon offering a versatile option, for creating, running, and managing containers on Linux systems.
  • Container: A container is like a self-contained software package that houses an application along with all its components ensuring performance across different environments.
  • Image: An image serves as a design or model for constructing containers. It includes the application file system, settings, and operational instructions.
  • PS Command: The 'ps command in Podman functions as a tool that displays real-time information on containers, similar, to the 'ps command found in Unix-based systems.

Podman ps Command Overview

The 'ps' command in Podman works like a window into your world showing you the current status of all active containers and a bunch of related details. Like the command in classic Unix systems, Podmans 'ps command gives you a rundown of running containers packed with key info, like IDs original images, status, port configurations, and more.

Differences between Podman ps and Docker ps

Both Podman and Docker provide containerization features. There are slight differences, in how their 'ps commands work due to their architectural variances. Podman's approach without a daemon leads to an output format that emphasizes user interactions and efficient container handling. In contrast, Dockers 'ps command might include information related to its reliance on a daemon, for operations.


Docker

Podman

Daemon

Uses the Docker

Daemonless architecture

Root

Runs containers as root-only

Runs containers as root and as non-root

Images

Can Build container images

Uses Buildah to build container images

Architecture

Client-server

Fork-exec

All-in-one

Yes

No

Docker-swarm

Supported

Not Supported

Docker-compose

Supported

Supported

Pods

Supports pods (via Docker Compose or Swarm)

Supports pods natively

Ecosystem

Larger, more mature

Growing rapidly

Use Cases

Enterprise environments, large-scale deployments

Development,smaller deployments, rootless containers

Runs natively on

Linux, macOS and Windows

Linux,macOS and Windows (with WSL)

Podman ps Command Options and Outputs

The podman ps command provides a view presenting each container in a table format, with information.

podman ps
  • Container ID: A must have, for performing targeted tasks like pausing or restarting a container.
  • Image: The image utilized to set up the container helps in tracking the version of applications in use.
  • Command: The particular action being executed by the container provides insights, into its function.
  • Created: Shows the timestamp indicating when the container was first established.
  • Status: Indicates whether the container is currently running, paused or stopped.
  • Ports: Describes any port setups exposed by the container for interacting with the host system to ensure network connectivity.
  • Names: Names assigned by users to identify and manage containers.

Monitoring Running Containers With ps Command

podman ps 
Screenshot-2024-08-27-194650
  • Filters the list to only show running containers.
podman ps -f "status=running"
podman ps -f "status=running"

Monitoring Stopped Containers With ps Command

  • Lists all containers, including stopped ones.
podman ps -a 
podman ps -a
  • Filters the list to show only stopped containers.
podman ps -f "status=exited"
Screenshot-2024-08-27-200414

Monitoring with Advanced Techniques With ps Command

  • Get real-time resource usage statistics for all running containers.
podman ps -q | xargs podman stats
podman ps -q
  • View the logs of all stopped containers to investigate failures.
podman ps -a -f "status=exited" -q | xargs podman logs 
Screenshot-2024-08-27-200945

Best Practices for 'ps' in Automation

  • Use -q or --quiet to get just the container IDs, making it easy to parse in scripts.
  • Combine with --filter to target specific containers based on their attributes.
  • Use podman events to monitor container lifecycle events in real-time and trigger actions based on them.

Filtering by Specific Criteria

  • Shows only the container named "my_web_server".
podman ps -f "name=my_web_server" 
podman ps -f "name=my_web_server"
  • Lists all containers created from the "nginx:latest" image or any of its descendants.
podman ps -f "ancestor=nginx:latest" 
Screenshot-2024-08-27-202405

Examples

  • Web Server Monitoring: Regularly checking with the command "podman ps f 'name=my_web_server'" helps in keeping the web server container and running smoothly.
  • Debugging a Crashed Application: When troubleshooting an application using "podman ps a f 'exited=0'" can help locate containers that exited due, to errors allowing for an investigation.
  • Resource Optimization: For optimizing resources utilizing podman ps along with monitoring tools can assist in identifying containers that are consuming resources enabling optimization opportunities.

Article Tags :

Similar Reads