docker的命令分两类Management Commands和Commands

Management Commands是对docker里的对象进行管理的

[root@localhost docker_test]# dockerUsage:    docker [OPTIONS] COMMANDA self-sufficient runtime for containersOptions:--config string      Location of client config files (default "/root/.docker")-D, --debug              Enable debug mode-H, --host list          Daemon socket(s) to connect to-l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")--tls                Use TLS; implied by --tlsverify--tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")--tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")--tlskey string      Path to TLS key file (default "/root/.docker/key.pem")--tlsverify          Use TLS and verify the remote-v, --version            Print version information and quitManagement Commands:builder     Manage buildsconfig      Manage Docker configscontainer   Manage containersengine      Manage the docker engineimage       Manage imagesnetwork     Manage networksnode        Manage Swarm nodesplugin      Manage pluginssecret      Manage Docker secretsservice     Manage servicesstack       Manage Docker stacksswarm       Manage Swarmsystem      Manage Dockertrust       Manage trust on Docker imagesvolume      Manage volumesCommands:attach      Attach local standard input, output, and error streams to a running containerbuild       Build an image from a Dockerfilecommit      Create a new image from a container's changescp          Copy files/folders between a container and the local filesystemcreate      Create a new containerdiff        Inspect changes to files or directories on a container's filesystemevents      Get real time events from the serverexec        Run a command in a running containerexport      Export a container's filesystem as a tar archive
  history     Show the history of an imageimages      List imagesimport      Import the contents from a tarball to create a filesystem imageinfo        Display system-wide informationinspect     Return low-level information on Docker objectskill        Kill one or more running containersload        Load an image from a tar archive or STDINlogin       Log in to a Docker registrylogout      Log out from a Docker registrylogs        Fetch the logs of a containerpause       Pause all processes within one or more containersport        List port mappings or a specific mapping for the containerps          List containerspull        Pull an image or a repository from a registrypush        Push an image or a repository to a registryrename      Rename a containerrestart     Restart one or more containersrm          Remove one or more containersrmi         Remove one or more imagesrun         Run a command in a new containersave        Save one or more images to a tar archive (streamed to STDOUT by default)search      Search the Docker Hub for imagesstart       Start one or more stopped containersstats       Display a live stream of container(s) resource usage statisticsstop        Stop one or more running containerstag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGEtop         Display the running processes of a containerunpause     Unpause all processes within one or more containersupdate      Update configuration of one or more containersversion     Show the Docker version informationwait        Block until one or more containers stop, then print their exit codesRun 'docker COMMAND --help' for more information on a command.
[root@localhost docker_test]#

docker删除container

[root@localhost docker_test]# docker container ls -a #查看所有container
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
1c4586fe95ee        centos              "/bin/bash"         18 minutes ago      Exited (127) 16 seconds ago                         agitated_banzai
7b1a19f1db72        bigni/test3         "/soeasy.sh"        26 minutes ago      Exited (0) 26 minutes ago                           quizzical_elgamal
8c3e652d7321        bigni/test3         "/soeasy.sh"        26 minutes ago      Exited (0) 26 minutes ago                           xenodochial_diffie
80e6e373f1d4        cfbfd0a29d1c        "/soeasy.sh"        About an hour ago   Exited (0) About an hour ago                        dreamy_mendel
934e574a077d        e2b5b08cc31c        "/soeasy.sh"        About an hour ago   Exited (1) About an hour ago                        nostalgic_lehmann
871a7d62acc1        f5620b92331c        "/soeasy2"          About an hour ago   Exited (15) About an hour ago                       serene_spence
72fd56c76100        hello-world         "/hello"            44 hours ago        Exited (0) 44 hours ago                             trusting_pasteur
[root@localhost docker_test]# docker rm 1c4586fe95ee #通过container id 删除container,
1c4586fe95ee
[root@localhost docker_test]# docker container ls -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
7b1a19f1db72        bigni/test3         "/soeasy.sh"        28 minutes ago      Exited (0) 28 minutes ago                           quizzical_elgamal
8c3e652d7321        bigni/test3         "/soeasy.sh"        28 minutes ago      Exited (0) 28 minutes ago                           xenodochial_diffie
80e6e373f1d4        cfbfd0a29d1c        "/soeasy.sh"        About an hour ago   Exited (0) About an hour ago                        dreamy_mendel
934e574a077d        e2b5b08cc31c        "/soeasy.sh"        About an hour ago   Exited (1) About an hour ago                        nostalgic_lehmann
871a7d62acc1        f5620b92331c        "/soeasy2"          About an hour ago   Exited (15) About an hour ago                       serene_spence
72fd56c76100        hello-world         "/hello"            44 hours ago        Exited (0) 44 hours ago                             trusting_pasteur
[root@localhost docker_test]# docker rm 7b #只要能区分,container id可以不写全
7b
[root@localhost docker_test]# docker container ls -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
8c3e652d7321        bigni/test3         "/soeasy.sh"        30 minutes ago      Exited (0) 30 minutes ago                           xenodochial_diffie
80e6e373f1d4        cfbfd0a29d1c        "/soeasy.sh"        About an hour ago   Exited (0) About an hour ago                        dreamy_mendel
934e574a077d        e2b5b08cc31c        "/soeasy.sh"        About an hour ago   Exited (1) About an hour ago                        nostalgic_lehmann
871a7d62acc1        f5620b92331c        "/soeasy2"          About an hour ago   Exited (15) About an hour ago                       serene_spence
72fd56c76100        hello-world         "/hello"            44 hours ago        Exited (0) 44 hours ago                             trusting_pasteur
[root@localhost docker_test]# docker ps -a #通过docker提供的commands 可以做到manager commands的效果,还简便些。
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS                          PORTS               NAMES
8c3e652d7321        bigni/test3         "/soeasy.sh"        31 minutes ago      Exited (0) 31 minutes ago                           xenodochial_diffie
80e6e373f1d4        cfbfd0a29d1c        "/soeasy.sh"        About an hour ago   Exited (0) About an hour ago                        dreamy_mendel
934e574a077d        e2b5b08cc31c        "/soeasy.sh"        About an hour ago   Exited (1) About an hour ago                        nostalgic_lehmann
871a7d62acc1        f5620b92331c        "/soeasy2"          About an hour ago   Exited (15) About an hour ago                       serene_spence
72fd56c76100        hello-world         "/hello"            44 hours ago        Exited (0) 44 hours ago                             trusting_pasteur
[root@localhost docker_test]#

批量删除container

[root@localhost docker_test]# docker container ls -qa #q参数和下面awk过滤效果类似
8c3e652d7321
80e6e373f1d4
934e574a077d
871a7d62acc1
72fd56c76100
[root@localhost docker_test]# docker container ls -a | awk '{print$1}'
CONTAINER
8c3e652d7321
80e6e373f1d4
934e574a077d
871a7d62acc1
72fd56c76100
[root@localhost docker_test]# docker rm $(docker container ls -qa) #删除
8c3e652d7321
80e6e373f1d4
934e574a077d
871a7d62acc1
72fd56c76100
[root@localhost docker_test]# docker container ls -a
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
[root@localhost docker_test]# 

删除image

[root@localhost docker_test]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
bigni/test3         latest              cfbfd0a29d1c        About an hour ago   202MB
bigni/test2         latest              e2b5b08cc31c        About an hour ago   36B
bigni/test1         latest              f5620b92331c        2 hours ago         861kB
ubuntu              14.04               2c5e00d77a67        7 weeks ago         188MB
centos              latest              9f38484d220f        3 months ago        202MB
hello-world         latest              fce289e99eb9        6 months ago        1.84kB
[root@localhost docker_test]# docker rmi bigni/test3 #通过repository删除
Untagged: bigni/test3:latest
Deleted: sha256:cfbfd0a29d1c13e7596dde977374fff34c384f65a50d80da4ffc9e8ae36a00fc
Deleted: sha256:9ae6ad56171a30de3d9f27c0015c5aaed332a82102bcae740ad50aee7145937f
Deleted: sha256:570ed3f49567e40d1810b6f29d951f09ad174132d83faef52b9a37b274a9402a
[root@localhost docker_test]# docker rmi e2b5b08cc31c #通过image id 删除
Untagged: bigni/test2:latest
Deleted: sha256:e2b5b08cc31c1ff0cfe13c94725ea658c08d1a222b25fd1bb979ff8fab04203e
Deleted: sha256:93d27c3e1b5b3ff9b4f9ce40af601bfb2dc26f29de06c129b6b28d4edc9098d5
Deleted: sha256:af79ac887464a533529523d6e2e8b780768de102ad87db7587c078dc0db1428e
[root@localhost docker_test]# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
bigni/test1         latest              f5620b92331c        2 hours ago         861kB
ubuntu              14.04               2c5e00d77a67        7 weeks ago         188MB
centos              latest              9f38484d220f        3 months ago        202MB
hello-world         latest              fce289e99eb9        6 months ago        1.84kB
[root@localhost docker_test]# 

转载于:https://www.cnblogs.com/laonicc/p/11143562.html

docker--删除container和image相关推荐

  1. docker删除所有容器_如何在Linux上创建,列出和删除Docker容器

    本篇文章介绍的内容是关于在Linux机器上创建,列出和删除docker容器,下面我们来看具体的内容. 我的官方群点击此处 1.启动Docker容器 使用下面的命令启动新的Docker容器.这将启动一个 ...

  2. docker 删除所有镜像_关于 Docker 镜像的操作,看完这篇就够啦 !(下)| 文末福利...

    紧接着上篇<关于 Docker 镜像的操作,看完这篇就够啦 !(上)>,奉上下篇 !!! 镜像作为 Docker 三大核心概念中最重要的一个关键词,它有很多操作,是您想学习容器技术不得不掌 ...

  3. docker 删除包含关键字的镜像_30分钟带你轻松掌握Docker原理

    前言 Docker是什么? Docker是Go语言开发实现的容器.2013年发布至今,备受推崇.相关文档.学习资料十分详尽.近期有docker相关项目,得重新学习一下.博客以笔记 为什么要使用 Doc ...

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

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

  5. Docker删除镜像/容器

    Docker删除镜像/容器 1.查看镜像 现在我们尝试删除第三个镜像也就是 image id 为 39f48bacf78c 的镜像 删除失败,提示我们要停止 e17a898b3a66 id的容器 2. ...

  6. docker 删除映像_创建自己的Docker映像(技术提示#57)

    docker 删除映像 Docker通过轻松构建和共享包含应用程序整个环境的映像来简化软件交付,例如,操作系统,JDK,数据库,WAR文件,应用程序所需的特定调整等. Docker包含三个主要组件: ...

  7. docker重启后启动失败Failed to start Docker Application Container Engine.

    刚刚弄了docker重启了一下,本来启动得好好的,重启系统后就不行了 一直给我报错 最开始是这样的 [root@server run]# systemctl status docker ● docke ...

  8. Docker的Container简介

    什么是Container 要有Container首先要有Image,也就是说Container是通过image创建的. Container是在原先的Image之上新加的一层,称作Container l ...

  9. Docker启动失败报错Failed to start Docker Application Container Engine解决方案

    在给一台腾讯云机器安装docker后发现无法启动,总是报错Failed to start Docker Application Container Engine,解决思路分享一下,以免各位童鞋踩坑. ...

  10. Ubuntu 16.04 安装 Docker - Dependency failed for Docker Application Container

    Docker 安装 由于 apt 官方库里的 Docker 版本可能比较旧,所以先卸载可能存在的旧版本: sudo apt-get remove docker docker-engine docker ...

最新文章

  1. Opencv 基础 MatOfByte创建和byte数组
  2. 香港的CIA线服务器是什么?
  3. .net平台的rabbitmq使用封装
  4. Hologres揭秘:高性能原生加速MaxCompute核心原理
  5. python 语句简写_自学Python-语句之列表推导式
  6. leetcode109. 有序链表转换二叉搜索树
  7. MySQL备份还原知识要点
  8. 找不到方向?10大热门大数据应用领域总有一款适合你
  9. 知群产品经理必修TOP班 学习笔记:电梯演讲和商业画布
  10. token 自动续期的方案
  11. jQuery详细教程,基础内容罗列
  12. vue移动端的日期插件带农历
  13. docker minio部署作为shareX截图软件的图床
  14. E - Competitive Seagulls(博弈)
  15. 第一届中兴捧月算法大赛迪杰斯特拉派解决方案
  16. MEM/MBA英语基础(08)复合句-状语从句
  17. OpenCV每日函数 结构分析和形状描述符(8) fitLine函数 拟合直线
  18. 56个有效且健康的减肥小绝招
  19. 对称矩阵到三对角矩阵的Lanczos推导(python,数值积分)
  20. 文本分类算法TextCNN

热门文章

  1. C 不使用其他库生成BMP图片
  2. 计算机网络中为什么引入IP地址?
  3. 090723 T Code Generate 的思考
  4. kafka sqs 与_RabbitMQ和Kafka的比较
  5. Java课设对对碰_java实现对对碰小游戏
  6. 图虫知识共享协议_缘之好物 篇二十:关怀父母的另类方案----新礼物:2019图虫影像历...
  7. Hibernate映射组件属性(一)
  8. 【渝粤题库】陕西师范大学201831 课程论 作业
  9. 贪心算法小记——代理服务器
  10. 本周ASP.NET英文技术文章推荐[07/22 - 07/28]:VS 2008、.NET 3.5、IronRuby、jQuery、ASP.NET AJAX、IIS7...