Docker 列出正在运行的容器

DockerDockerBeginner
立即练习

💡 本教程由 AI 辅助翻译自英文原版。如需查看原文,您可以 切换至英文原版

Introduction

Welcome to the future spaceport, where space shuttles from various galaxies land and depart. As the spaceport administrator, your responsibility is to oversee the flow of containers on the docking platforms to ensure smooth operations.

The goal of this lab is to familiarize you with the docker ps command, which is used to list the containers that are currently running on the spaceport. By the end of this lab, you will be able to identify and understand the running containers on the spaceport's platforms.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL docker(("`Docker`")) -.-> docker/ContainerOperationsGroup(["`Container Operations`"]) docker/ContainerOperationsGroup -.-> docker/ps("`List Running Containers`") subgraph Lab Skills docker/ps -.-> lab-271483{{"`Docker 列出正在运行的容器`"}} end

列出正在运行的容器

在这一步中,你将使用 docker ps 命令列出空间站平台上正在运行的容器。

  1. 在你的 zsh 终端中,执行以下命令以列出正在运行的容器:

    docker ps
  2. 输出应显示正在运行的容器的详细信息,包括它们的容器 ID、镜像、状态和其他相关信息。

按名称过滤正在运行的容器

在这一步中,你将根据容器名称过滤正在运行的容器并显示结果。

  1. 使用以下命令按名称过滤正在运行的容器,这里以 "jenkins" 为例:

    docker ps --filter "name=jenkins"
  2. 输出应仅显示具有指定名称的正在运行的容器。

显示所有正在运行和已停止的容器

在这一步中,你将使用带有附加标志的 docker ps 命令来显示正在运行和已停止的容器。

  1. 执行以下命令以显示所有容器,包括正在运行和已停止的容器:

    docker ps -a
  2. 输出应包含所有容器的详细信息,无论它们的运行状态如何。

总结

在本实验中,你学习了如何使用 docker ps 命令列出正在运行和已停止的容器,并根据指定条件过滤容器。这些知识将使你能够高效地管理和监控空间站平台上的容器,确保运营顺畅和太空旅行的无缝衔接。尽情探索 Docker 广阔宇宙中容器化的无限可能吧!

您可能感兴趣的其他 Docker 教程