Note:

Get started with Podman

Introduction

This lab gets you started using Podman on Oracle Linux 8. You will install Podman, pull an image from a repository, and use the image to run a container.

Objectives

In this lab, you’ll:

What Do You Need?

(Hands-on Lab) Connect to the Compute Instance

Note: This step is specific to the Oracle provided free lab environment.

To access the lab compute instance, first connect to the Oracle Cloud Infrastructure (OCI) Console and copy the compute instance Public IP address.

  1. Sign in to OCI Console, and select your Compartment.
  2. Click Instances.
  3. Copy the Public IP to a temporary location (such as a text file) on your computer.

    copy public ip

    To copy, highlight the IP address with the mouse and press Ctrl+C.

  4. Right-click the Virtual Desktop and select Open Terminal Here.
  5. Connect to the instance.

    ssh -i ../.ssh/id_rsa opc@<IP_ADDRESS_OF_COMPUTE_INSTANCE>
    

    Where <IP_ADDRESS_OF_COMPUTE_INSTANCE> is the IP address copied from the OCI Console.

  6. Accept the ECDSA key fingerprint.

    accept fingerprint

    You are now connected to the compute instance for this lab.

    successful connection

Install the Podman Package

  1. Open a terminal and connect to your Oracle Linux 8 instance.
  2. Install the container-tools module.

    sudo dnf module install container-tools:ol8
    

    This command will install the container-tools module which contains podman (if not already installed) and other tools, including skopeo and buildah.

    One essential tool is container-selinux which allows running podman as a non-root user on a SELinux enabled system.

  3. Dnf will display the container-tools module information, including a list of packages that will be installed and any dependencies.
  4. Type y to proceed with the installation.
  5. Installation of the container-tools module completes.
  6. Check the podman configuration and version.

    podman info
    

    info output

  7. The Podman commands can be run as a regular user, or as a sudo user with elevated privileges. To see further command details use the podman manual pages.

    man podman
    

    man page

Pull the Oracle Linux 8 Slim Image

Container images are hosted in a repository. By default, podman and skopeo on Oracle Linux 8 are configured to use the Oracle Container Registry, Docker Hub, Quay.io, Fedora, and CentOS registries.

  1. Start by listing the existing images in local storage.

    podman images
    

    images output

  2. Next, pull the oraclelinux:8-slim image.

    podman pull os/oraclelinux:8-slim
    

    pull output

  3. The image downloads to local system storage.
  4. Verify the image downloaded.

    podman images
    

    images output

Run the Oracle Linux 8 Slim Image

Start a container using the oraclelinux:8-slim image. The container in this lab will run an interactive bash terminal.

  1. Create a interactive container running the bash shell.

    podman run --rm -it oraclelinux:8-slim
    

    run2 results

    You are presented a bash terminal where you can run Linux commands within the container.

  2. Exit the container.

    exit
    

    The container is automatically removed after execution due to using the --rm option.

  3. Run the same command again, without the --rm option.

    podman run -it oraclelinux:8-slim
    

    run results

  4. Exit the container as before.
  5. Get a list of all containers in local storage.

    podman ps -a
    

    The -a ensures the output shows both running and non-running containers.

    ps output

Remove Existing Container and Image

Remove the container and image used in the lab leaving a clean environment.

  1. Remove the container created.

    podman rm <CONTAINER_ID>
    

    Where the <CONTAINER_ID> is determined by running podman ps -a.

    rm_output

  2. Verify the container was removed.

    podman ps -a
    

    ps_verify

  3. Remove the downloaded Oracle Linux 8 Slim image.

    podman rmi <IMAGE_ID>
    

    Where the <IMAGE_ID> is determined by running podman images.

    rmi output

Learn More

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

For product documentation, visit Oracle Help Center.