docker的命令分两类Management Commands和Commands

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

[root@localhost docker_test]# docker

Usage:    docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
--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 quit Management Commands:
builder Manage builds
config Manage Docker configs
container Manage containers
engine Manage the docker engine
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes Run '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" minutes ago Exited () seconds ago agitated_banzai
7b1a19f1db72 bigni/test3 "/soeasy.sh" minutes ago Exited () minutes ago quizzical_elgamal
8c3e652d7321 bigni/test3 "/soeasy.sh" minutes ago Exited () minutes ago xenodochial_diffie
80e6e373f1d4 cfbfd0a29d1c "/soeasy.sh" About an hour ago Exited () About an hour ago dreamy_mendel
934e574a077d e2b5b08cc31c "/soeasy.sh" About an hour ago Exited () About an hour ago nostalgic_lehmann
871a7d62acc1 f5620b92331c "/soeasy2" About an hour ago Exited () About an hour ago serene_spence
72fd56c76100 hello-world "/hello" hours ago Exited () 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" minutes ago Exited () minutes ago quizzical_elgamal
8c3e652d7321 bigni/test3 "/soeasy.sh" minutes ago Exited () minutes ago xenodochial_diffie
80e6e373f1d4 cfbfd0a29d1c "/soeasy.sh" About an hour ago Exited () About an hour ago dreamy_mendel
934e574a077d e2b5b08cc31c "/soeasy.sh" About an hour ago Exited () About an hour ago nostalgic_lehmann
871a7d62acc1 f5620b92331c "/soeasy2" About an hour ago Exited () About an hour ago serene_spence
72fd56c76100 hello-world "/hello" hours ago Exited () 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" minutes ago Exited () minutes ago xenodochial_diffie
80e6e373f1d4 cfbfd0a29d1c "/soeasy.sh" About an hour ago Exited () About an hour ago dreamy_mendel
934e574a077d e2b5b08cc31c "/soeasy.sh" About an hour ago Exited () About an hour ago nostalgic_lehmann
871a7d62acc1 f5620b92331c "/soeasy2" About an hour ago Exited () About an hour ago serene_spence
72fd56c76100 hello-world "/hello" hours ago Exited () 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" minutes ago Exited () minutes ago xenodochial_diffie
80e6e373f1d4 cfbfd0a29d1c "/soeasy.sh" About an hour ago Exited () About an hour ago dreamy_mendel
934e574a077d e2b5b08cc31c "/soeasy.sh" About an hour ago Exited () About an hour ago nostalgic_lehmann
871a7d62acc1 f5620b92331c "/soeasy2" About an hour ago Exited () About an hour ago serene_spence
72fd56c76100 hello-world "/hello" hours ago Exited () 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 hours ago 861kB
ubuntu 14.04 2c5e00d77a67 weeks ago 188MB
centos latest 9f38484d220f months ago 202MB
hello-world latest fce289e99eb9 months ago .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 hours ago 861kB
ubuntu 14.04 2c5e00d77a67 weeks ago 188MB
centos latest 9f38484d220f months ago 202MB
hello-world latest fce289e99eb9 months ago .84kB
[root@localhost docker_test]#

docker--删除container和image的更多相关文章

  1. Failed to start Docker Application Container

    [root@localhost ~]# systemctl status docker.service ● docker.service - Docker Application Container ...

  2. Failed to start Docker Application Container Engine.

    [root@dockertest ~]# systemctl status docker.service● docker.service - Docker Application Container ...

  3. Docker 容器(container)及资源限制

    Container: 既然container是由image运行起来的,那么是否可以理解为container和image有某种关系?先来看张图: 其实可以理解为container只是基于image之后的 ...

  4. 如何获取 docker 容器(container)的 ip 地址

    1. 进入容器内部后 cat /etc/hosts 会显示自己以及(– link)软连接的容器IP 2.使用命令 docker inspect --format '{{ .NetworkSetting ...

  5. 如何获取 docker 容器(container)的 ip 地址(转)

    1. 进入容器内部后 cat /etc/hosts 会显示自己以及(– link)软连接的容器IP 2.使用命令 docker inspect --format '{{ .NetworkSetting ...

  6. [问题] docker: Failed to start Docker Application Container Engine.

    docker无法启动: # systemctl restart docker Job for docker.service failed because the control process exi ...

  7. 014-docker-终端获取 docker 容器(container)的 ip 地址

    1. 进入容器内部后 cat /etc/hosts 会显示自己以及(– link)软连接的容器IP 2.使用命令 docker inspect --format '{{ .NetworkSetting ...

  8. 启动docker报Failed to start Docker Application Container Engine.解决

    [root@docker ~]# systemctl status docker.service● docker.service - Docker Application Container Engi ...

  9. Centos7服务器安装Docker及Docker镜像加速,Docker删除

    Centos7服务器安装Docker及Docker镜像加速,Docker删除 1.Centos7服务器安装Docker 1.1 root账户登录,查看内核版本如下 1.1.1 卸载服务器旧版本Dock ...

  10. docker起不来报错:Failed to start Docker Application Container Engine.

    报错信息如下: [root@localhost localdisk]# systemctl restart docker Job for docker.service failed because t ...

随机推荐

  1. mybatis小技巧

    本节主要讲解mybatis如下五个方面的内容: foreach 批量插入 模糊查询like的写法 #{}和${}的区别 解决实体类中的属性名和表中的字段名不一致问题 由于每次建立工程比较复杂,可以参考 ...

  2. OpenCV2马拉松第9圈——再谈对照度(对照度拉伸,直方图均衡化)

    收入囊中 lookup table 对照度拉伸 直方图均衡化 葵花宝典 lookup table是什么东西呢? 举个样例,假设你想把图像颠倒一下,f[i] = 255-f[i],你会怎么做? for( ...

  3. Elasticsearch7.3开启x-pack验证

    原文 Elasticsearch7开启x-pack验证 前言 在Elasticsearch7.3,x-pack已经作为默认的插件集成在Elasticsearch里面了,所以无需在bin/elastic ...

  4. casperjs-options

    The Casper class The easiest way to get a casper instance is to use the module's create() method: 最简 ...

  5. picker多级选择器的使用————小程序

    picker多级选择器的使用----小程序 picker是选择器来着,既然选择了,就希望可以获取选择的数据. index.html <view>picker获取数据</view> ...

  6. Oracle之子查询:Top-N问题

    学习了SQL子查询,遇到个Top-N问题,即:加入有张工资表(这里使用Oracle SCOTT用户的emp表),需要查找工资最高的3个员工信息,以下列格式输出: 乍眼一看,这很简单啊,对sal进行排序 ...

  7. AtCoder Beginner Contest 130 F Minimum Bounding Box 三分法求极值(WA)

    题意:给n个点的起始坐标以及他们的行走方向,每一单位时间每个点往它的方向移动一单位.问最小能包围所有点的矩形. 解法:看到题目求极值,想了想好像可以用三分法求极值,虽然我也不能证明面积是个单峰函数. ...

  8. vue 如何读取编译携带的参数

    vue 环境有很多套,我们需要根据不同环境设置不同的一些参数,如何不装任何依赖的情况下获取参数 下面是我制作官网,需要根据开发还是生产环境配置不同CDN,用vue-cli2+webpack,配置是再: ...

  9. 【leetcode】435. Non-overlapping Intervals

    题目如下: Given a collection of intervals, find the minimum number of intervals you need to remove to ma ...

  10. shell脚本编写nginx部署脚本

    下面为shell脚本编写的nginx的安装及修改nginx.conf的脚本,脚本比较简单: #!/bin/bash function yum_install(){ yum install epel-r ...