Manage and configure containers

Gabby is RHEL Sysadmin at IBM:

  • Her RHEL server is Gabby_RHEL_Server_01
  • Her username: gabby.caldwell
  • Her professionalism: she never runs commands as root, and she has both the LFCS certification and the RHCSA certificartion.
  • Her task: teach a group of 5 LFCS candidates this LFCS objective: Manage and configure containers.

Please generate and explain example commands to help Gabby to teach this task.

As Gabby is an experienced RHEL Sysadmin with the LFCS and RHCSA certifications, she can effectively teach the group of LFCS candidates how to manage and configure containers. Here are some example commands she can use, while adhering to her professionalism of not running commands as root:

  1. Install Docker:
    • sudo dnf install docker
    • Gabby can explain that Docker is a popular containerization platform and this command installs Docker on the RHEL server.
  2. Start the Docker service:
    • systemctl --user start docker
    • This command starts the Docker service as the current user. Gabby can emphasize the importance of running services within the user's context to maintain security and isolation.
  3. Enable Docker to start at boot:
    • systemctl --user enable docker
    • Gabby can teach the group how to enable the Docker service to start automatically at boot time within the user's context.
  4. Pull a container image from Docker Hub:
    • docker pull <image-name>
    • Gabby can explain that Docker Hub is a repository of container images, and this command pulls the specified image from Docker Hub onto the RHEL server.
  5. List downloaded container images:
    • docker images
    • Gabby can show the group how to use this command to view a list of container images that have been downloaded on the RHEL server.
  6. Run a container from an image:
    • docker run <image-name>
    • Gabby can demonstrate how to use this command to start a container from a specific image. She can explain that running a container creates an instance of the image as a live, isolated environment.
  7. List running containers:
    • docker ps
    • This command allows Gabby to show the group the currently running containers on the RHEL server.
  8. Stop a running container:
    • docker stop <container-id>
    • Gabby can teach how to stop a running container using its unique container ID.

These example commands provide a foundation for managing and configuring containers using Docker. Gabby's expertise and certifications will help her effectively guide the LFCS candidates in understanding containerization concepts and performing container-related tasks on their RHEL systems.

Does the docker ps command output show the container id?

Yes, the docker ps command does show the container ID as part of its output. The docker ps command is used to list the currently running containers on the system. The output typically includes several columns of information, and one of those columns is the Container ID.

Here's an example of the output of the docker ps command:

CONTAINER ID   IMAGE           COMMAND       CREATED         STATUS        PORTS   NAMES
f8a2b80a8e45   nginx:latest    "nginx -g ..."  2 hours ago   Up 2 hours    80/tcp   webserver

In this example, the first column labeled "CONTAINER ID" shows the unique identifier of the running container, which is f8a2b80a8e45. Each container has its own unique ID, allowing for easy reference and management of containers.

Gabby can explain to the LFCS candidates that the container ID is used to perform various operations on a specific container, such as stopping it (docker stop <container-id>), inspecting its details, or executing commands within the container.

By understanding the container ID within the docker ps output, Gabby and the LFCS candidates can effectively manage and interact with running Docker containers.

Gabby will not run all of these commands with sudo, correct?

You're correct. As per Gabby's professionalism of not running commands as root, she would not run all of these commands with sudo. In the provided examples, only the command for installing Docker (sudo dnf install docker) requires elevated privileges since it involves installing software on the system.

For the remaining commands, which are related to managing and interacting with Docker containers, Gabby can run them without sudo. These commands do not modify the system configuration or require administrative access. Instead, they operate within the context of the user running the commands, typically the user associated with the Docker daemon.

Therefore, Gabby would run the commands for starting the Docker service, enabling Docker at boot, pulling container images, listing images, running containers, listing running containers, and stopping containers without sudo. These operations can be performed by a regular user who has the necessary permissions to interact with Docker.

By adhering to her professionalism and only using sudo when necessary, Gabby maintains a secure and controlled environment while effectively teaching the LFCS candidates how to manage and configure containers on their RHEL systems.

You should also read:

Configure a caching DNS server

Segun is a RHEL Sysadmin at Red Hat. He administers RHEL_Server_047, and his username is segun.okuns. His supervisor wants Segun to demonstrate how…