Manage Containers: Basic Operations

LinuxLinuxBeginner
Practice Now

Introduction

As a system administrator, you need to be proficient in managing containers, which are lightweight and portable application packages. In this challenge, you will learn how to perform basic container management tasks such as running, starting, stopping, and listing running containers using the Docker command-line interface.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/BasicSystemCommandsGroup(["`Basic System Commands`"]) linux/BasicSystemCommandsGroup -.-> linux/echo("`Text Display`") subgraph Lab Skills linux/echo -.-> lab-389463{{"`Manage Containers: Basic Operations`"}} end

Manage Containers

Tasks

  • Run a container based on the nginx image
  • Start the container
  • Stop the container
  • List all running containers

Requirements

  • Run the container in the background (detached mode)
  • Use the container name my-nginx
  • Verify the container is running using the docker ps command
  • Stop the container using the docker stop command
  • List all running containers using the docker ps command

Example

After running the container, you should see the following output when listing the running containers:

CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS     NAMES
d1234567890   nginx     "/docker-entrypoint.…"   10 seconds ago  Up 8 seconds   80/tcp    my-nginx

After stopping the container, the docker ps command should not show any running containers.

Summary

In this challenge, you learned how to perform basic container management tasks using the Docker command-line interface. You practiced running, starting, stopping, and listing running containers. This knowledge is essential for system administrators who need to manage and maintain containerized applications in their infrastructure.

Other Linux Tutorials you may like