Manage Containers With Podman and Skopeo

Red Hat Enterprise LinuxBeginner
Practice Now

Introduction

As a system administrator working with Red Hat Enterprise Linux (RHEL), managing containerized applications is a fundamental skill. In this challenge, you will use the command-line tools podman and skopeo to perform essential container management tasks. You will practice pulling images from a public registry, running them as containers, inspecting their configuration, and copying images to a local registry.

Pull and Run a Container Image

Your first task is to download a container image from a public registry and run it on your local system. You will use the nginx web server image, a popular choice for demonstrating container functionality.

Tasks

  • Pull the latest nginx container image from the docker.io registry using the podman command.
  • Run a container from the nginx image and verify that it is operational.

Requirements

  • The nginx container must be named my-nginx.
  • The container must run in the background (detached mode).
  • The container's port 80 must be mapped to port 8080 on your local machine.

Example

After successfully running the container, you can test its accessibility. The curl command should return the default Nginx welcome page.

$ curl http://localhost:8080

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
...
</html>
✨ Check Solution and Practice

Inspect a Container

After running a container, you often need to retrieve detailed information about its configuration, network settings, and mounted volumes. The podman inspect command provides this information in a structured JSON format.

Tasks

  • Inspect the running my-nginx container.
  • Redirect the output of the inspection to a file.

Requirements

  • Use the podman inspect command to get details about the my-nginx container.
  • Save the JSON output to a file named nginx-inspect.json inside the ~/project/containers/ directory.

Example

The nginx-inspect.json file will contain a large JSON array with all the configuration details of the container. You can view its contents with the cat or less command.

$ cat ~/project/containers/nginx-inspect.json
[
    {
        "Id": "a933dd...c8e",
        "Created": "2023-10-27T10:30:00.123456789Z",
        "Path": "/docker-entrypoint.sh",
        "Args": [
            "nginx",
            "-g",
            "daemon off;"
        ],
        "State": {
...
✨ Check Solution and Practice

Copy a Container Image with Skopeo

skopeo is a powerful tool for moving container images between different types of storage, such as public registries, local storage, and private registries. In this step, you will copy the nginx image to a local container registry that is running on your machine.

By default, Podman and Skopeo will not push images to an insecure (HTTP) registry. You must first configure your system to trust the local registry using the modern v2 registry configuration format.

Tasks

  • Configure your system to allow pushing images to the insecure local registry at localhost:5000.
  • Use skopeo to copy the nginx:latest image from docker.io to your local registry.
  • Pull the image from your local registry into Podman's local storage to verify the copy was successful.

Requirements

  • Edit the /etc/containers/registries.conf file to configure localhost:5000 as an insecure registry using the v2 format. You will need sudo privileges for this.
  • Use skopeo copy to copy the docker.io/library/nginx:latest image.
  • The destination for the image in the local registry should be localhost:5000/my-local-nginx:latest.
  • After copying, use podman pull to retrieve localhost:5000/my-local-nginx:latest.
✨ Check Solution and Practice

Summary

In this challenge, you have learned the essential skills for managing containers on a Red Hat Enterprise Linux system. You successfully used podman to pull an image, run it as a named container with port mapping, and inspect its detailed configuration. Furthermore, you practiced a critical real-world task: configuring an insecure registry and using skopeo to copy an image from a public source to a private, local registry. These commands are fundamental tools for any system administrator working in a modern, containerized environment.