本文翻译自:How to list containers in Docker

There's a command to list images, docker images , but there doesn't seem to be a corresponding docker containers . 有一个命令可以列出镜像, docker images ,但是似乎没有相应的docker containers

Other than becoming root and looking into /var/lib/docker there doesn't seem a way to do that. 除了成为root并查看/var/lib/docker ,似乎没有其他方法可以做到。 Am I missing something? 我想念什么吗? Is that something one isn't supposed to do? 那是不应该做的事情吗?


#1楼

参考:https://stackoom.com/question/18exV/如何在Docker中列出容器


#2楼

To show only running containers use the given command: 要仅显示正在运行的容器,请使用给定命令:

docker ps

To show all containers use the given command: 要显示所有容器,请使用给定命令:

docker ps -a

To show the latest created container (includes all states) use the given command: 要显示最新创建的容器 (包括所有状态),请使用给定命令:

docker ps -l

To show n last created containers (includes all states) use the given command: 要显示n个最后创建的容器 (包括所有状态),请使用给定命令:

docker ps -n=-1

To display total file sizes use the given command: 要显示总文件大小,请使用给定命令:

docker ps -s

The content presented above is from docker.com . 上面显示的内容来自docker.com 。

In the new version of Docker, commands are updated, and some management commands are added: 在新版本的Docker中,命令已更新,并添加了一些管理命令:

docker container ls

It is used to list all the running containers. 它用于列出所有正在运行的容器。

docker container ls -a

And then, if you want to clean them all, 然后,如果您要清洁它们,

docker rm $(docker ps -aq)

It is used to list all the containers created irrespective of its state. 它用于列出所有创建的容器,无论其状态如何。

And to stop all the Docker containers (force) 并停止所有Docker容器(强制执行)

docker rm -f $(docker ps -a -q)

Here the container is the management command. 这里的容器是管理命令。


#3楼

Note that some time ago there was an update to this command. 请注意,前段时间对该命令进行了更新。 It will not show the container size by default (since this is rather expensive for many running containers). 默认情况下,它不会显示容器的大小(因为这对于许多正在运行的容器来说是相当昂贵的)。 Use docker ps -s to display container size as well. 使用docker ps -s可以显示容器大小。


#4楼

docker ps -s will show the size of running containers only. docker ps -s将仅显示正在运行的容器的大小。

To check the size of all containers use docker ps -as 要检查所有容器的大小,请使用docker ps -as


#5楼

To list only the containers SHA1: 仅列出容器SHA1:

docker ps -aq --no-trunc

That way, you can use the list of all containers for other commands (which accept multiple container ids as parameters). 这样,您可以将所有容器的列表用于其他命令(这些命令接受多个容器ID作为参数)。

For example, to list only the name of all containers (since docker ps list only their names with other information): 例如, 列出所有容器的名称 (因为docker ps仅列出其名称以及其他信息):

docker inspect --format='{{.Name}}' $(sudo docker ps -aq --no-trunc)

#6楼

I got the error message Cannot connect to the Docker daemon. 我收到错误消息Cannot connect to the Docker daemon. I forgot I am running the daemon as root and needed sudo : 我忘了我以root身份运行守护进程,并且需要sudo

$ sudo docker ps

如何在Docker中列出容器相关推荐

  1. 如何在docker中运行MySQL实例(转载)

    如何在docker中运行MySQL实例 转自:https://blog.csdn.net/siying8419/article/details/79670246 通常初学者学习docker时,不太清楚 ...

  2. docker中使用git_如何在 Docker 中使用 Docker

    1. 典型适用场景 在 CI 中,通常会有一个 CI Engine 负责解析流程,控制整个构建过程,而将真正的构建交给 Agent 去完成.例如,Jenkins .GitLab 均是如此. 如下图, ...

  3. 如何在Docker中使用安卓模拟器+Appium

    https://hub.docker.com/r/budtmo/docker-android-x86-9.0 docker pull budtmo/docker-android-x86-9.0 htt ...

  4. deb包一般放在linux的哪个目录下,技术|如何在 Linux 中列出通过 RPM 或者 DEB 包安装的文件...

    你是否想要了解安装包中各个文件在 Linux 系统中安装(位于)的位置?我们将在本文介绍如何列出文件的来源,或存在于某个特定包或者一组软件包中的文件. 这篇文章可以帮你轻松地找到重要的软件包文件,如配 ...

  5. linux 找到安装的软件包,如何在 Linux 中列出可用的软件包组

    原标题:如何在 Linux 中列出可用的软件包组 编译自: https://www.2daygeek.com/how-to-list-an-available-package-groups-in-li ...

  6. docker 删除映像_如何在Docker中删除映像和容器

    docker 删除映像 Docker RMI (Docker rmi) docker rmi removes images by their ID. docker rmi通过其ID删除图像. To r ...

  7. docker ps 列出容器 命令简介

    目录 语法说明 实例 列表字段介绍 容器状态介绍 语法说明 docker ps [OPTIONS] options 说明 option 作用 -a, --all 显示全部容器(默认只显示运行中的容器) ...

  8. mysql显示表已存在_「Docker系列」 如何在Docker中部署MySQL数据库?

    Docker为部署和测试应用程序和数据库提供了许多优势,这些应用程序和数据库是应用程序不可或缺的一部分,因此很值得学习如何在Docker容器中部署和运行数据库. 本文中,我们会重点关注如下重点: 为M ...

  9. docker中的容器和镜像

    最近学习了docker,感觉容器和镜像学的有点模糊. 特别是镜像和容器,感觉完全分不开,所以在此学习,然后总结了一下,便于后面的学习. *************** 补充:经过我的一段时间使用,现在 ...

最新文章

  1. Spring Boot 入门例子 Hello world - TerryHe 博客园
  2. YonStore应用+摩天知识,用友树立云生态新标杆
  3. Android Studio 插件开发详解一:入门练手
  4. javascript arguments
  5. [转载] python学习笔记2--操作符,数据类型和内置功能
  6. 新手篇 | K8S配置最佳实践
  7. 剑指offer 最小的k个数 leetcode 215. Kth Largest Element in an Array
  8. 在英特尔® 架构平台上开发和优化基于 NDK 的 Android 游戏应用
  9. 如何提高WEB程序的效率
  10. micro 和 macro F1 值 的区别?
  11. 周鸿祎《智能主义》读书笔记
  12. 交换机和路由器之间区别
  13. EduSoho网校系统产品更新:PPT动画转码
  14. 交叉引用跳转不到后面_参考文献如何正确标注引用而不会变红?
  15. 关于ETD.sys的系统蓝屏问题的解决
  16. Permission denied: user=dr.who, access=READ_EXECUTE, inode=/tmp:root:supergroup:drwx------
  17. SMETA验厂咨询,由于两种模式所需的审核天数不同,总的费用存在差异
  18. 计算机换系统之后无法打印,打印机win7系统正常打印,换成win10后打印机驱动消失无法打印?...
  19. 获取DLL运行时路径的方法
  20. Shellshock漏洞那些事:网络安全噩梦的开始

热门文章

  1. angular启动过程分析
  2. android 创建文件夹,文件需要注意的格式
  3. 用户界面和逻辑应该分离
  4. NSUserDefault的使用
  5. 安装SQL2005示例数据库
  6. C语言中的undefined behavior系列(2)-- lifetime of object
  7. 通过zabbix获取数据库连接的信息及部分扩展
  8. Zabbix通过自动发现监控端口
  9. 详解 MySQL 基准测试和 sysbench 工具
  10. 教你在 CentOS 8上安装GCC实现开发编译功能