docker image management commands

Image management commands

docker build : Command used to create an image using a Dockerfile
docker build [OPTIONS] PATH | URL | -
OPTIONS说明:
--add-host :向hosts文件中添加自定义 host:ip 映射
--build-arg=[] :设置镜像创建时的变量;
--cache-from :指定镜像用作当前构建的缓存镜像
--cgroup-parent :容器的可选父cgroup
--compress : 使用gzip压缩构建上下文
--cpu-period :限制 CPU CFS周期;
--cpu-quota :限制 CPU CFS配额;
-c,--cpu-shares :设置 cpu 使用权重;
--cpuset-cpus :指定使用的CPU id;
--cpuset-mems :指定使用的内存 id;
--disable-content-trust :跳过镜像校验,默认为true;
-f,--file :指定要使用的Dockerfile路径;
--force-rm :不论构建是否成功,总是删除中间容器,默认false。注意:中间容器;
--iidfile :将镜像ID写入到文件
--isolation :使用容器隔离技术;
    linux系统:只支持default,即linux命名空间隔离技术
    windows系统:
        default:表示使用docker守护进程配置的选项,否则默认使用process选项
    process:命名空间隔离
    hyperv:基于Hyper-V 管理程序基于分区的隔离

--label=[] :设置镜像使用的元数据;
-m :设置内存最大值;
--memory-swap :设置Swap的最大值为内存+swap,"-1"表示不限swap;
--network: 在构建期间为RUN指令设置网络模式(默认“default”)与docker run指令无关
--no-cache :创建镜像的过程不使用缓存;
--pull :总是尝试去更新镜像的新版本;
--quiet, -q :安静模式,成功后只输出镜像 ID;
--rm :构建成功后,删除中间容器,默认true。注意:中间容器,不是镜像;
--security-opt :安全选项
--shm-size :设置/dev/shm的大小,默认值是64M;/dev/shm 是基于内存的tmpfs文件系统。
--ulimit :Ulimit配置。
--tag, -t : 镜像的名字及标签,通常 name:tag 或者 name 格式;可以在一次构建中为一个镜像设置
多个标签。
--target : 设置要生成的目标生成阶段
--ulimit : Ulimit 选项
docker images : list local images
docker images [OPTIONS] [REPOSITORY[:TAG]]
OPTIONS说明:
-a :列出本地所有的镜像(含中间映像层,默认情况下,过滤掉中间映像层);
--digests :显示镜像的摘要信息;
-f :显示满足条件的镜像;
--format :指定返回值的模板文件;
--no-trunc :显示完整的镜像信息;
-q :只显示镜像ID

# 查看所有悬空镜像
docker images --filter dangling=true
# 清除所有悬空镜像
docker image prune
docker rmi: delete one or more local images
docker rmi [OPTIONS] IMAGE [IMAGE...]
OPTIONS说明:
-f :强制删除;
--no-prune :不移除该镜像的过程镜像,默认移除;
docker tag: mark the local image and classify it into a certain warehouse
docker tag [OPTIONS] IMAGE[:TAG] [REGISTRYHOST/][USERNAME/]NAME[:TAG]
docker save: save the specified image into a tar archive file
docker save [OPTIONS] IMAGE [IMAGE...]
OPTIONS 说明:
-o :输出到的文件。
docker load: Import the image exported using the docker save command
docker load [OPTIONS]
OPTIONS 说明:
--input , -i : 指定导入的文件,代替 STDIN。
--quiet , -q : 精简输出信息。
docker import : Create an image from an archive
docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
OPTIONS说明:
-c :应用docker 指令创建镜像;
-m :提交时的说明文字
docker commit: Create a new image from the container
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]
OPTIONS说明:
-a :提交的镜像作者;
-c :使用Dockerfile指令来创建镜像;
-m :提交时的说明文字;
-p :在commit时,将容器暂停

Mirror warehouse management commands

docker login: Log in to a Docker image warehouse. If the image warehouse address is not specified, the default is the official warehouse Docker Hub. docker logout: Log out of a Docker image warehouse. If the image warehouse address is not specified, the default is the official warehouse Docker Hub.
docker login [OPTIONS] [SERVER]
docker logout [OPTIONS] [SERVER]
OPTIONS说明:
-u :登陆的用户名
-p :登陆的密码
docker login -u 用户名 -p 密码
docker logout
docker pull: pull or update the specified image from the image warehouse
docker pull [OPTIONS] NAME[:TAG|@DIGEST]
OPTIONS说明:
-a :拉取所有 tagged 镜像
--disable-content-trust :忽略镜像的校验,默认开启
docker push: Upload the local image to the mirror warehouse. You must first log in to the mirror warehouse.
docker push [OPTIONS] NAME[:TAG]
OPTIONS说明:
--disable-content-trust :忽略镜像的校验,默认开启
docker search : Find images from Docker Hub
docker search [OPTIONS] TERM
OPTIONS说明:
--automated :只列出 automated build类型的镜像;
--no-trunc :显示完整的镜像描述;
-f <过滤条件>:列出收藏数不小于指定值的镜像

//Find all images from Docker Hub whose image name contains nginx and whose collection number is greater than 10

docker search -f stars=10 nginx

Parameter description:
NAME: The name of the image warehouse source
DESCRIPTION: The description of the image
stars: Similar The star in Github means like and like
OFFICIAL: Whether docker is officially released
 AUTOMATED: Automatically built

Guess you like

Origin blog.csdn.net/m0_68678128/article/details/134670710