文章目录
- docker help
- docker image相关的命令
- docker images 查看所有本地的主机上的镜像
- docker search 搜索镜像
- docker pull 下载镜像
- docker rmi 删除镜像
- 其他....
docker help
代码语言:javascript复制[root@VM-0-7-centos ~]# docker help
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/root/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context
set with "docker context use")
-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:
app* Docker App (Docker Inc., v0.9.1-beta3)
builder Manage builds
buildx* Build with BuildKit (Docker Inc., v0.6.1-docker)
config Manage Docker configs
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
scan* Docker Scan (Docker Inc., v0.8.0)
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.
To get more help with docker, check out our guides at https://docs.docker.com/go/guides/
[root@VM-0-7-centos ~]#
来看看几个和帮助相关的命令
代码语言:javascript复制# 显示docker版本信息
[root@VM-0-7-centos ~]# docker version
# 显示docker系统信息,包括镜像和容器数量
[root@VM-0-7-centos ~]# docker info
# 帮助信息
[root@VM-0-7-centos ~]# docker COMMAND --help
Run 'docker COMMAND --help' for more information on a command.
文档: https://docs.docker.com/engine/reference/commandline/docker/
docker image相关的命令
文档: https://docs.docker.com/engine/reference/commandline/image/
docker images 查看所有本地的主机上的镜像
https://docs.docker.com/engine/reference/commandline/images/
【使用】
代码语言:javascript复制 docker images [OPTIONS] [REPOSITORY[:TAG]]
【demo】
代码语言:javascript复制[root@VM-0-7-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest feb5d9fea6a5 12 days ago 13.3kB
代码语言:javascript复制# 解释
REPOSITORY 镜像的仓库源
TAG 镜像的标签
IMAGE ID 镜像的id
CREATED 镜像的创建时间
SIZE 镜像的大小
docker search 搜索镜像
代码语言:javascript复制[root@VM-0-7-centos ~]# docker search tomcat
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
tomcat Apache Tomcat is an open source implementati… 3146 [OK]
tomee Apache TomEE is an all-Apache Java EE certif… 93 [OK]
dordoka/tomcat Ubuntu 14.04, Oracle JDK 8 and Tomcat 8 base… 58 [OK]
kubeguide/tomcat-app Tomcat image for Chapter 1 31
consol/tomcat-7.0 Tomcat 7.0.57, 8080, "admin/admin" 18 [OK]
cloudesire/tomcat Tomcat server, 6/7/8 15 [OK]
aallam/tomcat-mysql Debian, Oracle JDK, Tomcat & MySQL 13 [OK]
arm32v7/tomcat Apache Tomcat is an open source implementati… 11
andreptb/tomcat Debian Jessie based image with Apache Tomcat… 10 [OK]
rightctrl/tomcat CentOS , Oracle Java, tomcat application ssl… 7 [OK]
arm64v8/tomcat Apache Tomcat is an open source implementati… 6
unidata/tomcat-docker Security-hardened Tomcat Docker container. 5 [OK]
amd64/tomcat Apache Tomcat is an open source implementati… 3
oobsri/tomcat8 Testing CI Jobs with different names. 2
cfje/tomcat-resource Tomcat Concourse Resource 2
jelastic/tomcat An image of the Tomcat Java application serv… 2
fabric8/tomcat-8 Fabric8 Tomcat 8 Image 2 [OK]
picoded/tomcat7 tomcat7 with jre8 and MANAGER_USER / MANAGER… 1 [OK]
99taxis/tomcat7 Tomcat7 1 [OK]
chenyufeng/tomcat-centos tomcat基于centos6的镜像 1 [OK]
ppc64le/tomcat Apache Tomcat is an open source implementati… 1
camptocamp/tomcat-logback Docker image for tomcat with logback integra… 1 [OK]
s390x/tomcat Apache Tomcat is an open source implementati… 0
softwareplant/tomcat Tomcat images for jira-cloud testing 0 [OK]
secoresearch/tomcat-varnish Tomcat and Varnish 5.0 0 [OK]
[root@VM-0-7-centos ~]#
代码语言:javascript复制# 可选项,通过镜像来过滤
-f, --filter=STARS=3000 # 搜索出来的镜像就是STARS大于3000的
[root@VM-0-7-centos ~]# docker search tomcat --filter=STARS=3000
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
tomcat Apache Tomcat is an open source implementati… 3146 [OK]
[root@VM-0-7-centos ~]#
docker pull 下载镜像
代码语言:javascript复制[root@VM-0-7-centos ~]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11507 [OK]
mariadb MariaDB Server is a high performing open sou… 4367 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Create… 850 [OK]
percona Percona Server is a fork of the MySQL relati… 557 [OK]
phpmyadmin phpMyAdmin - A web interface for MySQL and M… 336 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 91
mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 88
centurylink/mysql Image containing mysql. Optimized to be link… 59 [OK]
databack/mysql-backup Back up mysql databases to... anywhere! 51
prom/mysqld-exporter 42 [OK]
deitch/mysql-backup REPLACED! Please use http://hub.docker.com/r… 41 [OK]
tutum/mysql Base docker image to run a MySQL database se… 35
linuxserver/mysql A Mysql container, brought to you by LinuxSe… 31
schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 31 [OK]
mysql/mysql-router MySQL Router provides transparent routing be… 23
centos/mysql-56-centos7 MySQL 5.6 SQL database server 20
arey/mysql-client Run a MySQL client from a docker container 18 [OK]
fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron tas… 16 [OK]
yloeffler/mysql-backup This image runs mysqldump to backup data usi… 7 [OK]
openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6
devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offici… 3
jelastic/mysql An image of the MySQL database server mainta… 2
ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 2 [OK]
widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl… 1 [OK]
centos/mysql-80-centos7 MySQL 8.0 SQL database server 1
# 下载一个mysql的镜像,默认下载最新的镜像
[root@VM-0-7-centos ~]# docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
07aded7c29c6: Pull complete
f68b8cbd22de: Pull complete
30c1754a28c4: Pull complete
1b7cb4d6fe05: Pull complete
79a41dc56b9a: Pull complete
00a75e3842fb: Pull complete
b36a6919c217: Pull complete
635b0b84d686: Pull complete
6d24c7242d02: Pull complete
5be6c5edf16f: Pull complete
cb35eac1242c: Pull complete
a573d4e1c407: Pull complete
Digest: sha256:4fcf5df6c46c80db19675a5c067e737c1bc8b0e78e94e816a778ae2c6577213d
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
# 下载指定版本的镜像
[root@VM-0-7-centos ~]# docker pull mysql:5.7
5.7: Pulling from library/mysql
07aded7c29c6: Already exists
f68b8cbd22de: Already exists
30c1754a28c4: Already exists
1b7cb4d6fe05: Already exists
79a41dc56b9a: Already exists
00a75e3842fb: Already exists
b36a6919c217: Already exists
5e11fe494f45: Pull complete
9c7de1f889a7: Pull complete
cf6a13d05a76: Pull complete
fc5aa81f393a: Pull complete
Digest: sha256:360c7488c2b5d112804a74cd272d1070d264eef4812d9a9cc6b8ed68c3546189
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
# 查看下载的所有镜像
[root@VM-0-7-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql 5.7 9f35042c6a98 8 days ago 448MB
mysql latest 2fe463762680 8 days ago 514MB
hello-world latest feb5d9fea6a5 12 days ago 13.3kB
[root@VM-0-7-centos ~]#
docker rmi 删除镜像
代码语言:javascript复制[root@VM-0-7-centos ~]# docker rmi 9f35042c6a98
Untagged: mysql:5.7
Untagged: mysql@sha256:360c7488c2b5d112804a74cd272d1070d264eef4812d9a9cc6b8ed68c3546189
Deleted: sha256:9f35042c6a98363147ae456147643a3d14c484640f13f4ab207cf2c296839baf
Deleted: sha256:69a5732b5b989ff688326db6354b0f50165a71cfe7579b285054b561fb3c5143
Deleted: sha256:448b1f9cb8f126363f0e809e0e450c493ca1e725715127a258c5346fcae7cd8a
Deleted: sha256:4064542818b4bf92f293da870d3ea1413a20d0c1a83f72917c50986880255338
Deleted: sha256:8ca7f5e08bac7aa39cf9b8b79bf40669373b9aed45ec76eb0fa55109350b6672
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest 2fe463762680 8 days ago 514MB
hello-world latest feb5d9fea6a5 12 days ago 13.3kB
[root@VM-0-7-centos ~]#
【批量操作】
代码语言:javascript复制## 删除所有镜像
[root@VM-0-7-centos ~]# docker rmi -f $(docker images -aq)
[root@VM-0-7-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@VM-0-7-centos ~]##
# 删除多个镜像
[root@VM-0-7-centos ~]# docker rmi -f 镜像id 镜像id 镜像id
代码语言:javascript复制[root@VM-0-7-centos ~]# docker rmi -f $(docker images -aq)
Untagged: mysql:latest
Untagged: mysql@sha256:4fcf5df6c46c80db19675a5c067e737c1bc8b0e78e94e816a778ae2c6577213d
Deleted: sha256:2fe4637626805dc6df98d3dc17fa9b5035802dcbd3832ead172e3145cd7c07c2
Deleted: sha256:e00bdaa10222919253848d65585d53278a2f494ce8c6a445e5af0ebfe239b3b5
Deleted: sha256:83411745a5928b2a3c2b6510363218fb390329f824e04bab13573e7a752afd50
Deleted: sha256:e8e521a71a92aad623b250b0a192a22d54ad8bbeb943f7111026041dce20d94f
Deleted: sha256:024ee0ef78b28663bc07df401ae3a258ae012bd5f37c2960cf638ab4bc04fafd
Deleted: sha256:597139ec344c8cb622127618ae21345b96dd23e36b5d04b071a3fd92d207a2c0
Deleted: sha256:28909b85bd680fc47702edb647a06183ae5f3e3020f44ec0d125bf75936aa923
Deleted: sha256:4e007ef1e2a3e1e0ffb7c0ad8c9ea86d3d3064e360eaa16e7c8e10f514f68339
Deleted: sha256:b01d7bbbd5c0e2e5ae10de108aba7cd2d059bdd890814931f6192c97fc8aa984
Deleted: sha256:d98a368fc2299bfa2c34cc634fa9ca34bf1d035e0cca02e8c9f0a07700f18103
Deleted: sha256:95968d83b58ae5eec87e4c9027baa628d0e24e4acebea5d0f35eb1b957dd4672
Deleted: sha256:425adb901baf7d6686271d2ce9d42b8ca67e53cffa1bc05622fd0226ae40e9d8
Deleted: sha256:476baebdfbf7a68c50e979971fcd47d799d1b194bcf1f03c1c979e9262bcd364
Untagged: hello-world:latest
Untagged: hello-world@sha256:9ade9cc2e26189a19c2e8854b9c8f1e14829b51c55a630ee675a5a9540ef6ccf
Deleted: sha256:feb5d9fea6a5e9606aa995e879d862b825965ba48de054caab5ef356dc6b3412
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]#
[root@VM-0-7-centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@VM-0-7-centos ~]#
其他…
https://docs.docker.com/engine/reference/commandline/images/