(十三)鏡像小結
這一部分我們首先討論了鏡像的分層結構,然后學習了如何構建鏡像,最后實踐使用 Docker Hub 和本地 registry,
鏡像常用命令:
images 顯示鏡像串列
history 顯示鏡像構建歷史
commit 從容器創建新鏡像
build 從 Dockerfile 構建鏡像
tag 給鏡像打 tag
pull 從 registry 下載鏡像
push 將 鏡像 上傳到 registry
rmi 洗掉 Docker host 中的鏡像
search 搜索 Docker Hub 中的鏡像
(1)rmi
? rmi 只能洗掉 host 上的鏡像,不會洗掉 registry 的鏡像,如果一個鏡像對應了多個 tag,只有當最后一個 tag 被洗掉時,鏡像才被真正洗掉,例如 host 中 httpd 鏡像有兩個 tag:
root@cuiyongchao:/dockerfile# docker images httpd
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest 3dd970e6b110 2 weeks ago 138MB
httpd v1 3dd970e6b110 2 weeks ago 138MB
root@cuiyongchao:/dockerfile#
? 洗掉其中 debian:latest 只是洗掉了 latest tag,鏡像本身沒有洗掉,
root@cuiyongchao:/dockerfile# docker rmi httpd:latest
Untagged: httpd:latest
root@cuiyongchao:/dockerfile# docker images httpd
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd v1 3dd970e6b110 2 weeks ago 138MB
root@cuiyongchao:/dockerfile#
? 只有當 httpd: v1 也被洗掉時,整個鏡像才會被洗掉,
root@cuiyongchao:/dockerfile# docker rmi httpd:v1
Untagged: httpd:v1
Untagged: httpd@sha256:b82fb56847fcbcca9f8f162a3232acb4a302af96b1b2af1c4c3ac45ef0c9b968
root@cuiyongchao:/dockerfile# docker images httpd
REPOSITORY TAG IMAGE ID CREATED SIZE
root@cuiyongchao:/dockerfile#
(2)search
? search 讓我們無需打開瀏覽器,在命令列中就可以搜索 Docker Hub 中的鏡像,
root@cuiyongchao:/dockerfile# docker search httpd
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
httpd The Apache HTTP Server Project 3226 [OK]
centos/httpd-24-centos7 Platform for running Apache httpd 2.4 or bui… 36
centos/httpd 32 [OK]
arm32v7/httpd The Apache HTTP Server Project 9
arm64v8/httpd The Apache HTTP Server Project 5
polinux/httpd-php Apache with PHP in Docker (Supervisor, CentO… 4 [OK]
salim1983hoop/httpd24 Dockerfile running apache config 2 [OK]
lead4good/httpd-fpm httpd server which connects via fcgi proxy h… 1 [OK]
solsson/httpd-openidc mod_auth_openidc on official httpd image, ve… 1 [OK]
jonathanheilmann/httpd-alpine-rewrite httpd:alpine with enabled mod_rewrite 1 [OK]
publici/httpd httpd:latest 1 [OK]
dariko/httpd-rproxy-ldap Apache httpd reverse proxy with LDAP authent… 1 [OK]
clearlinux/httpd httpd HyperText Transfer Protocol (HTTP) ser… 1
appertly/httpd Customized Apache HTTPD that uses a PHP-FPM … 0 [OK]
interlutions/httpd httpd docker image with debian-based config … 0 [OK]
e2eteam/httpd 0
amd64/httpd The Apache HTTP Server Project 0
manasip/httpd 0
trollin/httpd 0
hypoport/httpd-cgi httpd-cgi 0 [OK]
manageiq/httpd_configmap_generator Httpd Configmap Generator 0 [OK]
itsziget/httpd24 Extended HTTPD Docker image based on the off… 0 [OK]
manageiq/httpd Container with httpd, built on CentOS for Ma… 0 [OK]
alvistack/httpd Docker Image Packaging for Apache 0 [OK]
dockerpinata/httpd 0
root@cuiyongchao:/dockerfile#
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/208641.html
標籤:其他
