docker基础:本地镜像管理相关命令,docker查看镜像命令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 ")

-c, --change list Apply Dockerfile instruction to the created image (default [])

-m, --message string Commit message

-p, --pause Pause container during commit (default true)

http://www.dengb.com/Linuxjc/1413446.htmlwww.dengb.comtruehttp://www.dengb.com/Linuxjc/1413446.htmlTechArticledocker基础:本地镜像管理相关命令,docker查看镜像命令 blog:https://www.cnblogs.com/Rohn/ 目录 本地镜像管理 列出本地镜像 删除本地镜像 标记本...

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐