Docker 的 镜像的常用命令

学习自:【狂神说Java】Docker最新超详细版教程通俗易懂_哔哩哔哩_bilibili

docker 的常用命令

docker version

docker info #信息

docker command --help #帮助命令

帮助文档:Reference documentation | Docker Documentation

镜像命令

查看镜像 docker images

[root@bogon ~]# docker images --help 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

[root@bogon ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql latest 4390e6453173 2 days ago 447MB mysql 5.7 c20987f18b13 8 months ago 448MB hello-world latest feb5d9fea6a5 11 months ago 13.3kB centos latest 5d0da3dc9764 11 months ago 231MB

查询镜像 docker search

[root@bogon ~]# docker search --help 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

--filter

eg :--filter is-automated=true --filter stars=3 --filter is-official=true

[root@bogon ~]# docker search --filter is-official=true --filter stars=3 busybox NAME DESCRIPTION STARS OFFICIAL AUTOMATED busybox Busybox base image. 2724 [OK]

[root@bogon ~]# docker search --format "{{.Name}}: {{.StarCount}}" nginx nginx: 17302 linuxserver/nginx: 175 bitnami/nginx: 140

-- limit int

[root@bogon ~]# docker search --limit 5 mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 13078 [OK] mariadb MariaDB Server is a high performing open sou… 5001 [OK] phpmyadmin phpMyAdmin - A web interface for MySQL and M… 614 [OK] percona Percona Server is a fork of the MySQL relati… 584 [OK] bitnami/mysql Bitnami MySQL Docker Image 76 [OK] [root@bogon ~]#

[root@bogon ~]# docker search --filter=stars=3 busybox NAME DESCRIPTION STARS OFFICIAL AUTOMATED busybox Busybox base image. 2724 [OK] radial/busyboxplus Full-chain, Internet enabled, busybox made f… 49 [OK] yauritux/busybox-curl Busybox with CURL 17 arm32v7/busybox Busybox base image. 10 arm64v8/busybox Busybox base image. 4 odise/busybox-curl 4 [OK] i386/busybox Busybox base image. 3 [root@bogon ~]#

--no-trunc

[root@bogon ~]# docker search --filter=stars=3 --no-trunc busybox NAME DESCRIPTION STARS OFFICIAL AUTOMATED busybox Busybox base image. 2724 [OK] radial/busyboxplus Full-chain, Internet enabled, busybox made from scratch. Comes in git and cURL flavors. 49 [OK] yauritux/busybox-curl Busybox with CURL 17 arm32v7/busybox Busybox base image. 10 arm64v8/busybox Busybox base image. 4 odise/busybox-curl 4 [OK] i386/busybox Busybox base image.

拉取镜像 docker pull

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

[root@bogon ~]# docker pull mysql:5.7 5.7: Pulling from library/mysql 72a69066d2fe: Pulling fs layer ...

移除镜像 docker rmi

[root@bogon ~]# docker rmi --help Usage: docker rmi [OPTIONS] IMAGE [IMAGE...] Remove one or more images Options: -f, --force Force removal of the image --no-prune Do not delete untagged parents

# 根据ID 移除 docker rmi fd484f19954f # 根据名字和版本移除 docker rmi test2:latest # 强制移除 docker rmi -f fd484f19954f

[root@bogon ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql latest 4390e6453173 2 days ago 447MB mysql 5.7 c20987f18b13 8 months ago 448MB hello-world latest feb5d9fea6a5 11 months ago 13.3kB centos latest 5d0da3dc9764 11 months ago 231MB [root@bogon ~]# docker rmi mysql:latest Untagged: mysql:latest Untagged: mysql@sha256:a3f9a4efbfb69420640a7412ad50ab15879b19372fd2f2a55d3d59074c65947c Deleted: sha256:4390e645317399cc7bcb50a5deca932a77a509d1854ac194d80ed5182a6b5096 Deleted: sha256:75dc8041405676eaae9d66c706391a721bdf4ad52e80e8f45d5e606da522a1bf Deleted: sha256:28084108988b802d5e1967199195d525699e7d600974715789efb66242e488b4 Deleted: sha256:aadb683b4e85d77a74eaf9b99cd8b779bbd05e1f78edfd77025c8942014579c3 Deleted: sha256:daf361feaa1dd1f58888bf1cd9b4c0bfab47f13e3fe0b19f880613b4040b08f3 Deleted: sha256:3e041f576b7d4441b85551571efb75a009e2b243fc7529310874577fb6150102 Deleted: sha256:b04fc441872cbf0a6f943134192675e80fe31057005fbddc7d6a6ca1e40e9a39 Deleted: sha256:6601932f6781c24cd1a322473e65c1f4e8b221d6e2a756ef6f7d6648422da63b Deleted: sha256:8e5ff63ed649c20ea0a586662a19e53dc9d4b641b56de30272a46824588411e9 Deleted: sha256:363fc02c77ec58f19c2c1e521248347b379d373e21afe843ca62947adf9f87e9 Deleted: sha256:e00f6b21d450e1bfcf88344147ed5dd99d7ebf610a2e22d48378bb7e72e40f98 Deleted: sha256:0935bd9056123d4e680c355dedaf3692ab4df0c2459d9ed6cf11ea0f8b6885b7 [root@bogon ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql 5.7 c20987f18b13 8 months ago 448MB hello-world latest feb5d9fea6a5 11 months ago 13.3kB centos latest 5d0da3dc9764 11 months ago 231MB 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值