4.1 查看版本信息

  1. docker version

4.2 查看系统信息

  1. docker info

4.3 帮助命令

  1. docker [命令] --help

https://docs.docker.com/engine/reference/commandline/cli/

4.4 查看镜像

  1. docker images
  2. Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
  3. List images
  4. Options:
  5. -a, --all Show all images (default hides intermediate images)
  6. --digests Show digests
  7. -f, --filter filter Filter output based on conditions provided
  8. --format string Pretty-print images using a Go template
  9. --no-trunc Don't truncate output
  10. -q, --quiet Only show image IDs

REPOSITORY TAG IMAGE ID CREATED SIZE
镜像仓库 标签 镜像id 创建时间 大小

  1. ╰─ docker images -a
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. ╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ at 15:30:35 ▓▒░
  4. ╰─ docker images -q
  5. ╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ at 15:30:39 ▓▒░
  6. ╰─
  • 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

  1. ```shell
  2. docker search xxx
  1. ╰─ docker search mysql
  2. NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  3. mysql MySQL is a widely used, open-source relation 11836 [OK]
  4. mariadb MariaDB Server is a high performing open sou 4506 [OK]
  5. mysql/mysql-server Optimized MySQL Server Docker images. Create 887 [OK]
  6. percona Percona Server is a fork of the MySQL relati 565 [OK]
  7. phpmyadmin phpMyAdmin - A web interface for MySQL and M 396 [OK]
  8. centos/mysql-57-centos7 MySQL 5.7 SQL database server 92
  9. mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr 90
  10. centurylink/mysql Image containing mysql. Optimized to be link 59 [OK]
  11. databack/mysql-backup Back up mysql databases to... anywhere! 54
  12. prom/mysqld-exporter 46 [OK]
  13. deitch/mysql-backup REPLACED! Please use http://hub.docker.com/r… 41 [OK]
  14. tutum/mysql Base docker image to run a MySQL database se 35
  15. linuxserver/mysql A Mysql container, brought to you by LinuxSe 34
  16. schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup 31 [OK]
  17. mysql/mysql-router MySQL Router provides transparent routing be 23
  18. centos/mysql-56-centos7 MySQL 5.6 SQL database server 21
  19. arey/mysql-client Run a MySQL client from a docker container 20 [OK]
  20. fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron tas 18 [OK]
  21. openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image 6
  22. devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offici 3
  23. ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 3 [OK]
  24. idoall/mysql MySQL is a widely used, open-source relation 3 [OK]
  25. jelastic/mysql An image of the MySQL database server mainta 2
  26. centos/mysql-80-centos7 MySQL 8.0 SQL database server 2
  27. widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl 1 [OK]
  28. ╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ at 15:33:02 ▓▒░
  29. ╰─

搜索过滤

  1. ╰─ docker search mysql --filter=STARS=3000
  2. NAME DESCRIPTION STARS OFFICIAL AUTOMATED
  3. mysql MySQL is a widely used, open-source relation 11836 [OK]
  4. mariadb MariaDB Server is a high performing open sou 4506 [OK]

4.6 拉取镜像

docker pull xxx

  1. ╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ at 15:35:44 ▓▒░
  2. ╰─ docker pull --help
  3. Usage: docker pull [OPTIONS] NAME[:TAG|@DIGEST]
  4. Pull an image or a repository from a registry
  5. Options:
  6. -a, --all-tags Download all tagged images in the repository
  7. --disable-content-trust Skip image verification (default true)
  8. --platform string Set platform if server is multi-platform capable
  9. -q, --quiet Suppress verbose output
  10. ╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ at 15:35:48 ▓▒░

这里以拉取mysql为例

  1. ╰─ docker pull mysql
  2. Using default tag: latest
  3. latest: Pulling from library/mysql
  4. ffbb094f4f9e: Pull complete
  5. df186527fc46: Pull complete
  6. fa362a6aa7bd: Pull complete
  7. 5af7cb1a200e: Pull complete
  8. 949da226cc6d: Pull complete
  9. bce007079ee9: Pull complete
  10. eab9f076e5a3: Pull complete
  11. 8a57a7529e8d: Pull complete
  12. b1ccc6ed6fc7: Pull complete
  13. b4af75e64169: Pull complete
  14. 3aed6a9cd681: Pull complete
  15. 23390142f76f: Pull complete
  16. Digest: sha256:ff9a288d1ecf4397967989b5d1ec269f7d9042a46fc8bc2c3ae35458c1a26727
  17. Status: Downloaded newer image for mysql:latest
  18. docker.io/library/mysql:latest
  1. ╰─ docker images -a
  2. REPOSITORY TAG IMAGE ID CREATED SIZE
  3. mysql latest bbf6571db497 2 weeks ago 516MB

4.7 删除镜像

docker rmi -f 镜像id

  1. ╰─ docker rm --help
  2. Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
  3. Remove one or more containers
  4. Options:
  5. -f, --force Force the removal of a running container (uses SIGKILL)
  6. -l, --link Remove the specified link
  7. -v, --volumes Remove anonymous volumes associated with the container
  1. ╰─ docker rmi -f mysql
  2. Untagged: mysql:latest
  3. Untagged: mysql@sha256:ff9a288d1ecf4397967989b5d1ec269f7d9042a46fc8bc2c3ae35458c1a26727
  4. Deleted: sha256:bbf6571db4977fe13c3f4e6289c1409fc6f98c2899eabad39bfe07cad8f64f67
  5. Deleted: sha256:a72da99dce60d6f8d4c4cffa4173153c990537fcdfaa27c35324c3348d55dd5c
  6. Deleted: sha256:8b535d432ef2fbd45d93958347b2587c5cbe334f07d6909ad9d2d480ebbafb65
  7. Deleted: sha256:14d13a3b33fc76839f156cd24b4636dab121e6d3d026cefa2985a4b89e9d4df8
  8. Deleted: sha256:77c21a5a897a1ba752f3d742d6c94ee7c6b0e373fd0aeecc4bf88b9a3982007e
  9. Deleted: sha256:189162becec8bb4588c54fb4ea7e62d20121812e68aeb0291fb4bb5df9ec0985
  10. Deleted: sha256:34980dadfd6a5bb9d7f9e8d4e408000e0a8f4840cc7d3092dc94357ebe7a89b6
  11. Deleted: sha256:15b2beb64a91785c8f3709ecd2410d13577b3174faad164524434ce6a7633506
  12. Deleted: sha256:e38dd14d47b61171927ea4b928f7296123b65a81ad1cfde8f5d00cadf1e81bbb
  13. Deleted: sha256:865abdfd8444741f581ce582e4ac5746c4a00c282febf65aa808a235ec7abf78
  14. Deleted: sha256:b1e35233e1ac953bd06fc8fa83afb3a88c39c1aeae0c89a46cb1b652d6821b38
  15. Deleted: sha256:3bcfdf6641227ff63e3ddf9e38e45cf317b178a50a664e45c6ae596107d5bc46
  16. Deleted: sha256:f11bbd657c82c45cc25b0533ce72f193880b630352cc763ed0c045c808ff9ae1
  17. ╭─░▒▓ ~/Downloads/darwin_amd64 ▓▒░──────────────────────────────────────────────────────────────░▒▓ at 15:44:31 ▓▒░
  18. ╰─

删除所有镜像

  1. docker rmi -f $(docker images -aq)