docker image常用的命令
Posted xie123
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了docker image常用的命令相关的知识,希望对你有一定的参考价值。
查看镜像 docker image ls
[root@sds-1 ~]# docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
linuxserver/nginx latest dd9aa5a82e20 7 days ago 160MB
mysql latest 62a9f311b99c 11 days ago 445MB
[root@sds-1 ~]#
删除镜像 docker image rm mysql
[root@sds-1 ~]# docker image rm mysql
Untagged: mysql:latest
Untagged: mysql@sha256:01cf53f2538aa805bda591d83f107c394adca8d31f98eacd3654e282dada3193
Deleted: sha256:62a9f311b99c24c0fde0a772abc6030bc48e5acc7d7416b8eeb72d3da1b4eb6c
Deleted: sha256:82aa89ee850095559cbbee1f9d4bdaf06e21e42712b5d1a8a1904907433a1af3
Deleted: sha256:36d3209ee2d8a848f1e0e2ba5659478bbb0b0ca05384d18d4dd3b0672b4010a8
Deleted: sha256:6d32091cb220b1edbc69f5273b28fbfa101454817c648486ad9a2af076914864
Deleted: sha256:7d573b2b106757175900238b651e16c932c0a2b869c4599003ce9ba3197631e3
Deleted: sha256:d70572fbf868824e1dd0a0bd684e3bf562bc007958225df91c4d4a77df693502
Deleted: sha256:dcab0fde696a660d7c3e45d4ac9ebe5e9ce43ece239c317d3447242cd84cd604
Deleted: sha256:5781a962b07d33d82e5a60f744b3f956a165a0d4126b236dcaf3257dd77a6603
Deleted: sha256:6a3139a04536b9c1b948e6868bfd6ddbc84d4f7dab4ee1fca9dd68bedae358ce
Deleted: sha256:e473ce839faf505ccdc9440441885908b276050fae3a77039d1224391065a2e6
Deleted: sha256:aa58c9ce77bf5364f06519d9fa2c6f4c85e123953d5c52b6587b738e887dda19
Deleted: sha256:59b4eb3bf015143f8688803a1ab730b574d85590559f02d26f176ea948277d37
Deleted: sha256:8fa655db5360a336ddd0256f573e27975628668063732ef91f820d4770db737c
[root@sds-1 ~]#
通过名字查找仓库中镜像 docker search nginx
[root@sds-1 ~]# docker search nginx
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
nginx Official build of Nginx. 11866 [OK]
jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 1641 [OK]
richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 736 [OK]
linuxserver/nginx An Nginx container, brought to you by LinuxS… 73
bitnami/nginx Bitnami nginx Docker Image 70 [OK]
tiangolo/nginx-rtmp Docker image with Nginx using the nginx-rtmp… 51 [OK]
nginxdemos/hello NGINX webserver that serves a simple page co… 24 [OK]
jc21/nginx-proxy-manager Docker container for managing Nginx proxy ho… 23
nginx/nginx-ingress NGINX Ingress Controller for Kubernetes 20
jlesage/nginx-proxy-manager Docker container for Nginx Proxy Manager 20 [OK]
schmunk42/nginx-redirect A very simple container to redirect HTTP tra… 17 [OK]
blacklabelops/nginx Dockerized Nginx Reverse Proxy Server. 12 [OK]
centos/nginx-18-centos7 Platform for running nginx 1.8 or building n… 11
centos/nginx-112-centos7 Platform for running nginx 1.12 or building … 10
nginxinc/nginx-unprivileged Unprivileged NGINX Dockerfiles 9
webdevops/nginx Nginx container 8 [OK]
nginx/nginx-prometheus-exporter NGINX Prometheus Exporter 5
sophos/nginx-vts-exporter Simple server that scrapes Nginx vts stats a… 5 [OK]
1science/nginx Nginx Docker images that include Consul Temp… 5 [OK]
mailu/nginx Mailu nginx frontend 3 [OK]
pebbletech/nginx-proxy nginx-proxy sets up a container running ngin… 2 [OK]
travix/nginx NGinx reverse proxy 2 [OK]
centos/nginx-110-centos7 Platform for running nginx 1.10 or building … 0
wodby/nginx Generic nginx 0 [OK]
ansibleplaybookbundle/nginx-apb An APB to deploy NGINX 0 [OK]
[root@sds-1 ~]#
下载镜像 docker image pull nginx
[root@sds-1 ~]# docker image pull nginx
Using default tag: latest
latest: Pulling from library/nginx
1ab2bdfe9778: Pull complete
a17e64cfe253: Pull complete
e1288088c7a8: Pull complete
Digest: sha256:53ddb41e46de3d63376579acf46f9a41a8d7de33645db47a486de9769201fec9
Status: Downloaded newer image for nginx:latest
[root@sds-1 ~]#
查看镜像的详情 docker image inspect nginx
[root@sds-1 ~]# docker image inspect nginx
[
"Id": "sha256:5a3221f0137beb960c34b9cf4455424b6210160fd618c5e79401a07d6e5a2ced",
"RepoTags": [
"nginx:latest"
],
"RepoDigests": [
"nginx@sha256:53ddb41e46de3d63376579acf46f9a41a8d7de33645db47a486de9769201fec9"
],
"Parent": "",
"Comment": "",
"Created": "2019-08-15T21:22:39.878636802Z",
"Container": "19511f9201c8b6b53f6ed218c5bd7a301caca9d9481e3e63e50a8177ff6986c6",
"ContainerConfig":
"Hostname": "19511f9201c8",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts":
"80/tcp":
,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NGINX_VERSION=1.17.3",
"NJS_VERSION=0.3.5",
"PKG_RELEASE=1~buster"
],
"Cmd": [
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"nginx\" \"-g\" \"daemon off;\"]"
],
"ArgsEscaped": true,
"Image": "sha256:c070d36aed6f1d6a0cadc7e863f6eabd5f27a62429d32cbb538efab49dd632db",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels":
"maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
,
"StopSignal": "SIGTERM"
,
"DockerVersion": "18.06.1-ce",
"Author": "",
"Config":
"Hostname": "",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts":
"80/tcp":
,
"Tty": false,
"OpenStdin": false,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"NGINX_VERSION=1.17.3",
"NJS_VERSION=0.3.5",
"PKG_RELEASE=1~buster"
],
"Cmd": [
"nginx",
"-g",
"daemon off;"
],
"ArgsEscaped": true,
"Image": "sha256:c070d36aed6f1d6a0cadc7e863f6eabd5f27a62429d32cbb538efab49dd632db",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels":
"maintainer": "NGINX Docker Maintainers <docker-maint@nginx.com>"
,
"StopSignal": "SIGTERM"
,
"Architecture": "amd64",
"Os": "linux",
"Size": 125958368,
"VirtualSize": 125958368,
"GraphDriver":
"Data":
"LowerDir": "/var/lib/docker/overlay2/517074f09b168bc7a1a5dcd4a7529fe75292415fd95282e83995fafdea2d870a/diff:/var/lib/docker/overlay2/81bb26023152a05850bf438ea79f11b16a429aa4f4bfe581497ac923f5d57ebe/diff",
"MergedDir": "/var/lib/docker/overlay2/4de1b4649ad1adbe811721e62c75391e51e3eb81b0be98acc2e4ab275257025f/merged",
"UpperDir": "/var/lib/docker/overlay2/4de1b4649ad1adbe811721e62c75391e51e3eb81b0be98acc2e4ab275257025f/diff",
"WorkDir": "/var/lib/docker/overlay2/4de1b4649ad1adbe811721e62c75391e51e3eb81b0be98acc2e4ab275257025f/work"
,
"Name": "overlay2"
,
"RootFS":
"Type": "layers",
"Layers": [
"sha256:1c95c77433e8d7bf0f519c9d8c9ca967e2603f0defbf379130d9a841cca2e28e", # 分层
"sha256:002a63507c1caa5cc0e1af10e5b888f6ba20d06275e989a452581d789a48948e",
"sha256:12fdf55172df870a613a79c4757006c5b28e66a8621c3e26916678378568f078"
]
,
"Metadata":
"LastTagTime": "0001-01-01T00:00:00Z"
]
[root@sds-1 ~]#
以上是关于docker image常用的命令的主要内容,如果未能解决你的问题,请参考以下文章