Docker 常用命令
Docker 常用命令

Docker 常用命令

Tags
Docker
CLI
Published
Published May 12, 2022
Author
Docker 常用命令记录
 

镜像常用命令

  • imags 显示镜像列表
docker images
notion image
  • history 显示镜像构建历史
docker history <imageId or image name> docker history <imageId or image name> --no-trunc # 不截断输出
notion image
  • commit 从容器创建新镜像 (更加推荐Dockerfile 创建镜像
docker commit <imageId> <image>
先运行1个容器,里面touch 1个文件
先运行1个容器,里面touch 1个文件
使用commit 命令 创建一个镜像后运行,刚才touch 的文件还在
使用commit 命令 创建一个镜像后运行,刚才touch 的文件还在
  • build 从Dockerfile构建镜像。
docker build -t <image:tag> <context dir path> -f <Dockerfile>
notion image
  • tag:给镜像打tag。
docker tag <image:tag> <image:newtag>
notion image
  • pull:从registry下载镜像。
  • push:将镜像上传到registry。
notion image
  • rmi:删除Docker host中的镜像。
docker rmi <imageId or imageName> ... # 可以删除多个
notion image