Docker环境上的一切操作都基于镜像之上的,所以我们先来了解下镜像的基本管理,简单管理是基于单镜像操作的。
显示本地镜像列表(等同于docker images):docker image ls
[root@localhost ~]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE thehunt33r/docker-brimir latest b7bf3e5cd2cf 2 years ago 1.19GB
查询镜像:docker search nginx
[root@localhost ~]# docker search nginx NAME DESCRIPTION STARS OFFICIAL AUTOMATED nginx Official build of Nginx. 10800 [OK] jwilder/nginx-proxy Automated Nginx reverse proxy for docker con… 1512 [OK] richarvey/nginx-php-fpm Container running Nginx + PHP-FPM capable of… 678 [OK] jrcs/letsencrypt-nginx-proxy-companion LetsEncrypt container to use with nginx as p… 472 [OK] webdevops/php-nginx Nginx with PHP-FPM 122 [OK] kitematic/hello-world-nginx A light-weight nginx container that demonstr… 119 zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server wi… 86 [OK] bitnami/nginx Bitnami nginx Docker Image 60 [OK] linuxserver/nginx An Nginx container, brought to you by LinuxS… 53 1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 48 [OK] tobi312/rpi-nginx NGINX on Raspberry Pi / armhf 24 [OK] nginx/nginx-ingress NGINX Ingress Controller for Kubernetes 15 blacklabelops/nginx Dockerized Nginx Reverse Proxy Server. 12 [OK] wodby/drupal-nginx Nginx for Drupal container image 11 [OK] centos/nginx-18-centos7 Platform for running nginx 1.8 or building n… 10 nginxdemos/hello NGINX webserver that serves a simple page co… 10 [OK] webdevops/nginx Nginx container 8 [OK] centos/nginx-112-centos7 Platform for running nginx 1.12 or building … 6 1science/nginx Nginx Docker images that include Consul Temp… 4 [OK] pebbletech/nginx-proxy nginx-proxy sets up a container running ngin… 2 [OK] travix/nginx NGinx reverse proxy 2 [OK] mailu/nginx Mailu nginx frontend 2 [OK] toccoag/openshift-nginx Nginx reverse proxy for Nice running on same… 1 [OK] ansibleplaybookbundle/nginx-apb An APB to deploy NGINX 0 [OK] wodby/nginx Generic nginx
下载镜像(等同于docker pull):docker image pull nginx #不指定版本标签为直接下载latest最新版本(版本标签查询:hub.docker.com)
[root@localhost ~]# docker image pull nginx Using default tag: latest latest: Pulling from library/nginx 5e6ec7f28fb7: Pull complete ab804f9bbcbe: Pull complete 052b395f16bc: Pull complete Digest: sha256:56bcd35e8433343dbae0484ed5b740843dd8bff9479400990f251c13bbb94763 Status: Downloaded newer image for nginx:latest [root@localhost ~]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE nginx latest 42b4762643dc 7 days ago 109MB thehunt33r/docker-brimir latest b7bf3e5cd2cf 2 years ago 1.19GB
删除本地Docker镜像(等同于docker rmi):docker image rm nginx
[root@localhost ~]# docker image rm nginx Untagged: nginx:latest Untagged: nginx@sha256:56bcd35e8433343dbae0484ed5b740843dd8bff9479400990f251c13bbb94763 Deleted: sha256:42b4762643dcc9bf492b08064b55fef64942f055f0da91289a8abf93c6d6b43c Deleted: sha256:e0e55dd2303b3e3ec852acae267d1f8a3eea27a22c64a5829304ecee4d3f559c Deleted: sha256:4062cf272cdd99e83b1c21f712e5e1359c91ecf92925e56c62133c3324b84e45 Deleted: sha256:3c816b4ead84066ec2cadec2b943993aaacc3fe35fcd77ada3d09dc4f3937313 [root@localhost ~]# docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE thehunt33r/docker-brimir latest b7bf3e5cd2cf 2 years ago 1.19GB