大家好,今天给大家介绍一下docker镜像的常见命令
查看docker版本
[root@localhost ~] Client: Docker Engine - Community Version: 20.10.12 API version: 1.41 Go version: go1.16.12 Git commit: e91ed57 Built: Mon Dec 13 11:45:41 2021 OS/Arch: linux/amd64 Context: default Experimental: true Server: Docker Engine - Community Engine: Version: 20.10.12 API version: 1.41 (minimum version 1.12) Go version: go1.16.12 Git commit: 459d0df Built: Mon Dec 13 11:44:05 2021 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.4.12 GitCommit: 7b11cfaabd73bb80907dd23182b9347b4245eb5d runc: Version: 1.0.2 GitCommit: v1.0.2-0-g52b36a2 docker-init: Version: 0.19.0 GitCommit: de40ad0
docker info //显示docker的系统信息
[root@localhost ~] Client: Context: default Debug Mode: false Plugins: app: Docker App (Docker Inc., v0.9.1-beta3) buildx: Docker Buildx (Docker Inc., v0.7.1-docker) scan: Docker Scan (Docker Inc., v0.12.0) Server: Containers: 0 Running: 0 Paused: 0 Stopped: 0 Images: 0 Server Version: 20.10.12 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: true userxattr: false Logging Driver: json-file Cgroup Driver: cgroupfs Cgroup Version: 1 Plugins: Volume: local Network: bridge host ipvlan macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc Default Runtime: runc Init Binary: docker-init containerd version: 7b11cfaabd73bb80907dd23182b9347b4245eb5d runc version: v1.0.2-0-g52b36a2 init version: de40ad0 Security Options: seccomp Profile: default Kernel Version: 3.10.0-862.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 974.6MiB Name: localhost.localdomain ID: 5YF7:DQV3:H353:2FGI:NJL4:E3AM:USRM:R5J2:B5V5:U3KT:LAQ2:IPCR Docker Root Dir: /var/lib/docker Debug Mode: false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Registry Mirrors: https://17o3zxc0.mirror.aliyuncs.com/ Live Restore Enabled: false
docker –help //显示docker命令的帮助文档
也可以看docker官网上提供的帮助
它的地址:docker的在线帮助点这里
查看docker镜像
[root@localhost ~] REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 5 months ago 13.3kB [root@localhost ~]
它的具体解释:
REPOSITORY :镜像的仓库源 TAG : 这是镜像的标签 IMAGE ID : 这是镜像的id CREATED 镜像的创建时间 SIZE 镜像的大小
有关这条命令的帮助
[root@localhost ~] 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@localhost ~]
这里注意两个: -a : 列出所有镜像(默认的) -q :只显示镜像的id
实操:
搜索镜像:
[root@localhost ~] NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 16426 [OK] bitnami/nginx Bitnami nginx Docker Image 120 [OK] bitnami/wordpress-nginx Bitnami Docker Image for WordPress with NGINX 56 [OK] ubuntu/nginx Nginx, a high-performance reverse proxy & we… 33 bitnami/nginx-ingress-controller Bitnami Docker Image for NGINX Ingress Contr… 16 [OK] rancher/nginx-ingress-controller 10 ibmcom/nginx-ingress-controller Docker Image for IBM Cloud Private-CE (Commu… 4 bitnami/nginx-ldap-auth-daemon 3 rancher/nginx-ingress-controller-defaultbackend 2 bitnami/nginx-exporter 2 circleci/nginx This image is for internal use 2 rancher/nginx 1 rancher/nginx-ingress-controller-amd64 0 rancher/nginx-conf 0 rancher/nginx-ssl 0 ibmcom/nginx-ppc64le Docker image for nginx-ppc64le 0 wallarm/nginx-ingress-controller Kubernetes Ingress Controller with Wallarm e… 0 ibmcom/nginx-ingress-controller-ppc64le Docker Image for IBM Cloud Private-CE (Commu… 0 rancher/nginx-proxy 0 bitnami/nginx-intel 0 wallarm/nginx-ingress-controller-amd64 Kubernetes Ingress Controller with Wallarm e… 0 ibmcom/nginx-ingress-controller-amd64 0 ibmcom/nginx-ingress-controller-s390x 0 kasmweb/nginx An Nginx image based off nginx:alpine and in… 0 wallarm/nginx-amd64 0
根据具体条件进行细致化的搜索
[root@localhost ~] NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 12215 [OK] mariadb MariaDB Server is a high performing open sou… 4689 [OK]
拉取镜像
[root@localhost ~] Using default tag: latest latest: Pulling from library/mysql 72a69066d2fe: Pull complete 93619dbc5b36: Pull complete 99da31dd6142: Pull complete 626033c43d70: Pull complete 37d5d7efb64e: Pull complete ac563158d721: Pull complete d2ba16033dad: Pull complete 688ba7d5c01a: Pull complete 00e060b6d11d: Pull complete 1c04857f594f: Pull complete 4d7cfa90e6ea: Pull complete e0431212d27d: Pull complete Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709 Status: Downloaded newer image for mysql:latest //这一行表示它的最新的镜像 docker.io/library/mysql:latest //这是它的真实地址
这条命令拉取的镜像,
默认使用最新的,也可以添加标签,使用指定的版本
docker pull mysql
和
docker pull docker.io/library/mysql:latest //这两条命令是等价的
可以指定它的版本:
[root@localhost ~] 5.7: Pulling from library/mysql 72a69066d2fe: Already exists 93619dbc5b36: Already exists 99da31dd6142: Already exists 626033c43d70: Already exists 37d5d7efb64e: Already exists ac563158d721: Already exists d2ba16033dad: Already exists 0ceb82207cd7: Pull complete 37f2405cae96: Pull complete e2482e017e53: Pull complete 70deed891d42: Pull complete Digest: sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94 Status: Downloaded newer image for mysql:5.7 docker.io/library/mysql:5.7 [root@localhost ~]
查看镜像:
[root@localhost ~] REPOSITORY TAG IMAGE ID CREATED SIZE mysql 5.7 c20987f18b13 2 months ago 448MB mysql latest 3218b38490ce 2 months ago 516MB hello-world latest feb5d9fea6a5 5 months ago 13.3kB [root@localhost ~]
删除指定id 的容器:
[root@localhost ~] Untagged: mysql:5.7 Untagged: mysql@sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94 Deleted: sha256:c20987f18b130f9d144c9828df630417e2a9523148930dc3963e9d0dab302a76 Deleted: sha256:6567396b065ee734fb2dbb80c8923324a778426dfd01969f091f1ab2d52c7989 Deleted: sha256:0910f12649d514b471f1583a16f672ab67e3d29d9833a15dc2df50dd5536e40f Deleted: sha256:6682af2fb40555c448b84711c7302d0f86fc716bbe9c7dc7dbd739ef9d757150 Deleted: sha256:5c062c3ac20f576d24454e74781511a5f96739f289edaadf2de934d06e910b92
docker rmi -f $(docker images -q) //删除所有的镜像 docker rmi -f 镜像id 镜像id 镜像 id //同时删除多个镜像
好了,有关于docker 镜像的常见命令就到这里了,谢谢大家
原文链接:https://blog.csdn.net/weixin_47556601/article/details/123317498?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522168994567316800225523234%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=168994567316800225523234&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-10-123317498-null-null.268%5Ev1%5Ekoosearch&utm_term=docker%E3%80%81wordpress%E3%80%81wordpress%E5%BB%BA%E7%AB%99%E3%80%81wordpress%E4%B8%BB%E9%A2%98%E3%80%81%E5%AE%B9%E5%99%A8%E9%95%9C%E5%83%8F%E3%80%81