4.1 查看版本信息
docker version
4.2 查看系统信息
docker info
4.3 帮助命令
docker [命令] --help
https://docs.docker.com/engine/reference/commandline/cli/
4.4 查看镜像
docker images
Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
List images
Options:
-a, --all Show all images (default hides intermediate images)
--digests Show digests
-f, --filter filter Filter output based on conditions provided
--format string Pretty-print images using a Go template
--no-trunc Don't truncate output
-q, --quiet Only show image IDs
REPOSITORY TAG IMAGE ID CREATED SIZE
镜像仓库 标签 镜像id 创建时间 大小
╰─ docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ ✔ at 15:30:35 ▓▒░
╰─ docker images -q
╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ ✔ at 15:30:39 ▓▒░
╰─
- a 显示所有镜像
- q 只显示id
4.5 搜索镜像
docker仓库查看
https://hub.docker.com/ ```shell Usage: docker search [OPTIONS] TERM
Search the Docker Hub for images
Options: -f, —filter filter Filter output based on conditions provided —format string Pretty-print search using a Go template —limit int Max number of search results (default 25) —no-trunc Don’t truncate output
```shell
docker search xxx
╰─ docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11836 [OK]
mariadb MariaDB Server is a high performing open sou… 4506 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Create… 887 [OK]
percona Percona Server is a fork of the MySQL relati… 565 [OK]
phpmyadmin phpMyAdmin - A web interface for MySQL and M… 396 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 92
mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 90
centurylink/mysql Image containing mysql. Optimized to be link… 59 [OK]
databack/mysql-backup Back up mysql databases to... anywhere! 54
prom/mysqld-exporter 46 [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… 34
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 21
arey/mysql-client Run a MySQL client from a docker container 20 [OK]
fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron tas… 18 [OK]
openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6
devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offici… 3
ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 3 [OK]
idoall/mysql MySQL is a widely used, open-source relation… 3 [OK]
jelastic/mysql An image of the MySQL database server mainta… 2
centos/mysql-80-centos7 MySQL 8.0 SQL database server 2
widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl… 1 [OK]
╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ ✔ at 15:33:02 ▓▒░
╰─
搜索过滤
╰─ docker search mysql --filter=STARS=3000
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11836 [OK]
mariadb MariaDB Server is a high performing open sou… 4506 [OK]
4.6 拉取镜像
docker pull xxx
╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ ✔ at 15:35:44 ▓▒░
╰─ docker pull --help
Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST]
Pull an image or a repository from a registry
Options:
-a, --all-tags Download all tagged images in the repository
--disable-content-trust Skip image verification (default true)
--platform string Set platform if server is multi-platform capable
-q, --quiet Suppress verbose output
╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ ✔ at 15:35:48 ▓▒░
这里以拉取mysql为例
╰─ docker pull mysql
Using default tag: latest
latest: Pulling from library/mysql
ffbb094f4f9e: Pull complete
df186527fc46: Pull complete
fa362a6aa7bd: Pull complete
5af7cb1a200e: Pull complete
949da226cc6d: Pull complete
bce007079ee9: Pull complete
eab9f076e5a3: Pull complete
8a57a7529e8d: Pull complete
b1ccc6ed6fc7: Pull complete
b4af75e64169: Pull complete
3aed6a9cd681: Pull complete
23390142f76f: Pull complete
Digest: sha256:ff9a288d1ecf4397967989b5d1ec269f7d9042a46fc8bc2c3ae35458c1a26727
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
╰─ docker images -a
REPOSITORY TAG IMAGE ID CREATED SIZE
mysql latest bbf6571db497 2 weeks ago 516MB
4.7 删除镜像
docker rmi -f 镜像id
╰─ docker rm --help
Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
Remove one or more containers
Options:
-f, --force Force the removal of a running container (uses SIGKILL)
-l, --link Remove the specified link
-v, --volumes Remove anonymous volumes associated with the container
╰─ docker rmi -f mysql
Untagged: mysql:latest
Untagged: mysql@sha256:ff9a288d1ecf4397967989b5d1ec269f7d9042a46fc8bc2c3ae35458c1a26727
Deleted: sha256:bbf6571db4977fe13c3f4e6289c1409fc6f98c2899eabad39bfe07cad8f64f67
Deleted: sha256:a72da99dce60d6f8d4c4cffa4173153c990537fcdfaa27c35324c3348d55dd5c
Deleted: sha256:8b535d432ef2fbd45d93958347b2587c5cbe334f07d6909ad9d2d480ebbafb65
Deleted: sha256:14d13a3b33fc76839f156cd24b4636dab121e6d3d026cefa2985a4b89e9d4df8
Deleted: sha256:77c21a5a897a1ba752f3d742d6c94ee7c6b0e373fd0aeecc4bf88b9a3982007e
Deleted: sha256:189162becec8bb4588c54fb4ea7e62d20121812e68aeb0291fb4bb5df9ec0985
Deleted: sha256:34980dadfd6a5bb9d7f9e8d4e408000e0a8f4840cc7d3092dc94357ebe7a89b6
Deleted: sha256:15b2beb64a91785c8f3709ecd2410d13577b3174faad164524434ce6a7633506
Deleted: sha256:e38dd14d47b61171927ea4b928f7296123b65a81ad1cfde8f5d00cadf1e81bbb
Deleted: sha256:865abdfd8444741f581ce582e4ac5746c4a00c282febf65aa808a235ec7abf78
Deleted: sha256:b1e35233e1ac953bd06fc8fa83afb3a88c39c1aeae0c89a46cb1b652d6821b38
Deleted: sha256:3bcfdf6641227ff63e3ddf9e38e45cf317b178a50a664e45c6ae596107d5bc46
Deleted: sha256:f11bbd657c82c45cc25b0533ce72f193880b630352cc763ed0c045c808ff9ae1
╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ ✔ at 15:44:31 ▓▒░
╰─
删除所有镜像
docker rmi -f $(docker images -aq)