Manage Containers: Basic Operations

Red Hat Enterprise LinuxBeginner
Practice Now

Introduction

As a Red Hat System Administrator, managing containers is a fundamental skill. In this challenge, you will practice the basic operations of container management using the podman command-line tool. You will learn how to run, list, and stop a container, which are essential tasks for daily administration.

Manage Containers with Podman

This challenge will guide you through the lifecycle of a container. You will use podman to run a new container, check its status, and then stop it.

Tasks

  • Run a container using the nginx image.
  • List the running containers to confirm it has started.
  • Stop the running container.
  • List the running containers again to confirm it has stopped.

Requirements

  • Use the podman command for all container operations.
  • Run a container from the docker.io/library/nginx image.
  • The container must be named my-nginx.
  • The container must run in the background (detached mode).
  • Use podman ps to verify the container's status.

Example

After running the container, the output of podman ps should look similar to this:

CONTAINER ID  IMAGE                           COMMAND               CREATED         STATUS             PORTS       NAMES
d1234567890a  docker.io/library/nginx:latest  nginx -g daemon o...  10 seconds ago  Up 8 seconds ago               my-nginx

After stopping the container, the podman ps command should produce no output, indicating that no containers are currently running.

Container Inspection and Management

Now that you have mastered the basic lifecycle operations, let's explore container inspection and management features. Understanding how to examine container details, access logs, and interact with running containers is essential for effective container administration.

Tasks

  • Start a new container using the httpd (Apache) image.
  • Inspect the container to view its configuration details.
  • Access the container's logs.
  • Execute a command inside the running container to explore its filesystem.

Requirements

  • Use the podman command for all container operations.
  • Run a container from the docker.io/library/httpd image.
  • The container must be named my-apache.
  • The container must run in the background (detached mode).
  • Use podman inspect to examine the container configuration.
  • Use podman logs to view container logs.
  • Use podman exec to run a command inside the container (e.g., ls /usr/local/apache2/htdocs/).

Example

After running the container, the podman inspect command should return detailed JSON configuration. The podman logs command should show Apache startup messages, and podman exec should allow you to explore the container's filesystem and verify it's working correctly.

Summary

In this challenge, you have learned the fundamental commands for managing containers with podman. You practiced how to run containers in detached mode, assign names to them, list running containers to check their status, and stop containers. Additionally, you learned essential container inspection and management skills including examining container configuration with podman inspect, accessing container logs with podman logs, and executing commands inside running containers with podman exec. These skills are a crucial foundation for any system administrator working in a modern, containerized RHEL environment.

✨ Check Solution and Practice✨ Check Solution and Practice