4.1 查看版本信息
docker version
4.2 查看系统信息
docker info
4.3 帮助命令
docker [命令] --help
https://docs.docker.com/engine/reference/commandline/cli/
4.4 查看镜像
docker imagesUsage: docker images [OPTIONS] [REPOSITORY[:TAG]]List imagesOptions:-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 -aREPOSITORY 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
```shelldocker search xxx
╰─ docker search mysqlNAME DESCRIPTION STARS OFFICIAL AUTOMATEDmysql 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 92mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 90centurylink/mysql Image containing mysql. Optimized to be link… 59 [OK]databack/mysql-backup Back up mysql databases to... anywhere! 54prom/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… 35linuxserver/mysql A Mysql container, brought to you by LinuxSe… 34schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 31 [OK]mysql/mysql-router MySQL Router provides transparent routing be… 23centos/mysql-56-centos7 MySQL 5.6 SQL database server 21arey/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… 6devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offici… 3ansibleplaybookbundle/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… 2centos/mysql-80-centos7 MySQL 8.0 SQL database server 2widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl… 1 [OK]╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ ✔ at 15:33:02 ▓▒░╰─
搜索过滤
╰─ docker search mysql --filter=STARS=3000NAME DESCRIPTION STARS OFFICIAL AUTOMATEDmysql 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 --helpUsage: docker pull [OPTIONS] NAME[:TAG|@DIGEST]Pull an image or a repository from a registryOptions:-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 mysqlUsing default tag: latestlatest: Pulling from library/mysqlffbb094f4f9e: Pull completedf186527fc46: Pull completefa362a6aa7bd: Pull complete5af7cb1a200e: Pull complete949da226cc6d: Pull completebce007079ee9: Pull completeeab9f076e5a3: Pull complete8a57a7529e8d: Pull completeb1ccc6ed6fc7: Pull completeb4af75e64169: Pull complete3aed6a9cd681: Pull complete23390142f76f: Pull completeDigest: sha256:ff9a288d1ecf4397967989b5d1ec269f7d9042a46fc8bc2c3ae35458c1a26727Status: Downloaded newer image for mysql:latestdocker.io/library/mysql:latest
╰─ docker images -aREPOSITORY TAG IMAGE ID CREATED SIZEmysql latest bbf6571db497 2 weeks ago 516MB
4.7 删除镜像
docker rmi -f 镜像id
╰─ docker rm --helpUsage: docker rm [OPTIONS] CONTAINER [CONTAINER...]Remove one or more containersOptions:-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 mysqlUntagged: mysql:latestUntagged: mysql@sha256:ff9a288d1ecf4397967989b5d1ec269f7d9042a46fc8bc2c3ae35458c1a26727Deleted: sha256:bbf6571db4977fe13c3f4e6289c1409fc6f98c2899eabad39bfe07cad8f64f67Deleted: sha256:a72da99dce60d6f8d4c4cffa4173153c990537fcdfaa27c35324c3348d55dd5cDeleted: sha256:8b535d432ef2fbd45d93958347b2587c5cbe334f07d6909ad9d2d480ebbafb65Deleted: sha256:14d13a3b33fc76839f156cd24b4636dab121e6d3d026cefa2985a4b89e9d4df8Deleted: sha256:77c21a5a897a1ba752f3d742d6c94ee7c6b0e373fd0aeecc4bf88b9a3982007eDeleted: sha256:189162becec8bb4588c54fb4ea7e62d20121812e68aeb0291fb4bb5df9ec0985Deleted: sha256:34980dadfd6a5bb9d7f9e8d4e408000e0a8f4840cc7d3092dc94357ebe7a89b6Deleted: sha256:15b2beb64a91785c8f3709ecd2410d13577b3174faad164524434ce6a7633506Deleted: sha256:e38dd14d47b61171927ea4b928f7296123b65a81ad1cfde8f5d00cadf1e81bbbDeleted: sha256:865abdfd8444741f581ce582e4ac5746c4a00c282febf65aa808a235ec7abf78Deleted: sha256:b1e35233e1ac953bd06fc8fa83afb3a88c39c1aeae0c89a46cb1b652d6821b38Deleted: sha256:3bcfdf6641227ff63e3ddf9e38e45cf317b178a50a664e45c6ae596107d5bc46Deleted: sha256:f11bbd657c82c45cc25b0533ce72f193880b630352cc763ed0c045c808ff9ae1╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ ✔ at 15:44:31 ▓▒░╰─
删除所有镜像
docker rmi -f $(docker images -aq)
