systemctl status docker
systemctl start docker
systemctl restart docker
systemctl daemon-reload # 重启守护进程
systemctl stop docker
systemctl enalbe docker
docker info
docker version
docker --help
docker 具体命令 --help
docker system COMMAND
Commands:
df Show docker disk usage
events Get real time events from the server
info Display system-wide information
prune Remove unused data
docker system df # 查看镜像、容器、数据卷所占空间
命令格式
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
--no-trunc Don't truncate output
-q, --quiet Only show image IDs
docker inspect [OPTIONS] NAME|ID [NAME|ID...]
Return low-level information on Docker objects
Options:
-f, --format string Format the output using the given Go template
-s, --size Display total file sizes if the type is container
--type string Return JSON for specified type
示例
docker images
docker images –q # 查看所有镜像的id
docker inspect 镜像名称 # 查看镜像信息
# 展示一个镜像形成历史
docker history [OPTIONS] IMAGE
Show the history of an image
Options:
--format string Pretty-print images using a Go template
-H, --human Print sizes and dates in human readable format (default true)
--no-trunc Don't truncate output
-q, --quiet Only show image IDs
docker search [OPTIONS] 镜像名称
#常用选项
--limit #返回镜像信息条数,默认25条
#示例
docker search 镜像名称:镜像版本
docker search --limit 5 镜像名称:镜像版本
#命令格式
docker pull [OPTIONS] NAME[:TAG|@DIGEST]
#示例
docker pull 镜像名称:镜像版本
# 如果不指定版本,则默认拉去最新版,不知道版本可以访问 https://hub.docker.com/ 查询;
# 命令格式
docker rmi [OPTIONS] IMAGE [IMAGE...]
Options:
-f, --force Force removal of the image #强制删除
--no-prune Do not delete untagged parents
#删除单个
docker rmi 镜像id或名称 # 删除指定本地镜像
#删除多个
docker rmi 镜像名1:版本 镜像名2:版本 镜像名3:版本···
#删除所有
docker rmi `docker images -aq` # 删除所有本地镜像
# 命令格式
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
-m, --message string Commit message
-p, --pause Pause container during commit (default true)
#示例
docker commit -a="sven" -m="配置JDK8" 容器ID IMAGE_NAME:TAG
导出
#命令格式
docker save [OPTIONS] IMAGE [IMAGE...]
# 含义及参数
Save one or more images to a tar archive (streamed to STDOUT by default)
Options:
-o, --output string Write to a file, instead of STDOUT
#示例
docker save -o ubuntu_20_04.tar ubuntu:20.04 # 打包一个镜像
docker save -o images.tar postgres:9.6 mongo:3.4 # 打包多个镜像到一个tar中
导入
#命令格式
docker load [OPTIONS]
# 含义及参数
Load an image from a tar archive or STDIN
Options:
-i, --input string Read from tar archive file, instead of STDIN
-q, --quiet Suppress the load output
#示例
docker load -i ubuntu_20_04.tar
导出
#命令格式
docker export [OPTIONS] CONTAINER
# 含义及参数
Export a container's filesystem as a tar archive
Options:
-o, --output string Write to a file, instead of STDOUT
#示例
docker export -o ubuntu_20_04.tar 容器id或名字
导入
#命令格式
docker import [OPTIONS] file|URL|- [REPOSITORY[:TAG]]
# 含义及参数
Import the contents from a tarball to create a filesystem image
Options:
-c, --change list Apply Dockerfile instruction to the created image
-m, --message string Set commit message for imported image
--platform string Set platform if server is multi-platform capable
#示例
docker import xxx.tar image_name:tag
参考连接:
https://blog.csdn.net/JineD/article/details/118761569