blog:https://www.cnblogs.com/Rohn/
目錄
- 本地鏡像管理
- 列出本地鏡像
- 洗掉本地鏡像
- 標記本地鏡像
- 使用DockerFile創建鏡像
- 查看指定鏡像的創建歷史
- 鏡像保存
- 鏡像匯入
- 從歸檔檔案中創建鏡像
- 從容器修改中創建新鏡像
本地鏡像管理
docker images: 列出本地鏡像;docker rmi:洗掉本地鏡像;docker tag:標記本地鏡像;docker build:使用DockerFile創建鏡像;docker history:查看指定鏡像的創建歷史;docker save:將指定鏡像保存成tar歸檔檔案;docker load:匯入使用docker save命令匯出的鏡像;docker import:從歸檔檔案中創建鏡像;docker commit:從容器修改中創建新的鏡像;
列出本地鏡像
語法如下:
docker images [OPTIONS] [REPOSITORY[:TAG]]
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
--help Print usage
--no-trunc Don't truncate output(顯示完整的鏡像資訊)
-q, --quiet Only show numeric IDs
洗掉本地鏡像
語法如下:
docker rmi [OPTIONS] IMAGE [IMAGE...]
Options:
-f, --force Force removal of the image(強制洗掉鏡像)
--no-prune Do not delete untagged parents(不移除該鏡像的程序鏡像,默認移除)
例如:
# 洗掉所有鏡像
docker rmi $(docker images -q)
# 批量洗掉無用鏡像
docker rmi $(docker images -f dangling=true)
標記本地鏡像
語法如下:
docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]
使用DockerFile創建鏡像
語法如下:
docker build [OPTIONS] PATH | URL | -
Options:
--build-arg list Set build-time variables (default [])
--cache-from stringSlice Images to consider as cache sources
--cgroup-parent string Optional parent cgroup for the container
--compress Compress the build context using gzip
--cpu-period int Limit the CPU CFS (Completely Fair Scheduler) period
--cpu-quota int Limit the CPU CFS (Completely Fair Scheduler) quota
-c, --cpu-shares int CPU shares (relative weight)
--cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
--disable-content-trust Skip image verification (default true)
-f, --file string Name of the Dockerfile (Default is 'PATH/Dockerfile')
--force-rm Always remove intermediate containers
--help Print usage
--isolation string Container isolation technology
--label list Set metadata for an image (default [])
-m, --memory string Memory limit
--memory-swap string Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--network string Set the networking mode for the RUN instructions during build (default "default")
--no-cache Do not use cache when building the image
--pull Always attempt to pull a newer version of the image
-q, --quiet Suppress the build output and print image ID on success
--rm Remove intermediate containers after a successful build (default true)
--security-opt stringSlice Security options
--shm-size string Size of /dev/shm, default value is 64MB
-t, --tag list Name and optionally a tag in the 'name:tag' format (default [])
--ulimit ulimit Ulimit options (default [])
查看指定鏡像的創建歷史
語法如下:
docker history [OPTIONS] IMAGE
Options:
-H, --human Print sizes and dates in human readable format (default true)
--no-trunc Don't truncate output
-q, --quiet Only show numeric IDs
鏡像保存
語法如下:
docker save [OPTIONS] IMAGE [IMAGE...]
Options:
-o, --output string Write to a file, instead of STDOUT
鏡像匯入
語法如下:
docker load [OPTIONS]
Options:
-i, --input string Read from tar archive file, instead of STDIN
-q, --quiet Suppress the load output
從歸檔檔案中創建鏡像
語法如下:
docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
Options:
-c, --change list Apply Dockerfile instruction to the created image (default [])
-m, --message string Set commit message for imported image
從容器修改中創建新鏡像
語法如下:
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
Options:
-a, --author string Author (e.g., "John Hannibal Smith <[email protected]>")
-c, --change list Apply Dockerfile instruction to the created image (default [])
-m, --message string Commit message
-p, --pause Pause container during commit (default true)
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/38441.html
標籤:Linux
下一篇:007.Nginx虛擬主機
