docker常用命令

  • 使用Dockerfile编译生成镜像
docker build -t 镜像标签名 .(Dockerfile存放的路径)
  • 拉取远程镜像
docker pull 远端镜像地址
  • docker save 打包(既可以对image打包也可以对container打包)
# 帮助
docker save --help 

Usage:  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 输出的tar包名 image名(container名) image名(container名) ...
  • 将tar载入镜像 docker load
# 帮助
docker load --help 

Usage:  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 tar包名
  • docker export 导出container
# 帮助
docker export --help

Usage:  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 导出的tar包名 container名
  • docker import导出的container
# 帮助
docker import --help 

Usage:  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
  • docker 删除本地image
# 帮助
docker rmi --help

Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images

Options:
  -f, --force      Force removal of the image
      --no-prune   Do not delete untagged parents
# 帮助
docker rm --help

Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers

Options:
  -f, --force     Force the removal of a running container (uses SIGKILL)
  -l, --link      Remove the specified link
  -v, --volumes   Remove the volumes associated with the container
  • docker 移除container
# 帮助
docker rm --help 

Usage:  docker rm [OPTIONS] CONTAINER [CONTAINER...]

Remove one or more containers

Options:
  -f, --force     Force the removal of a running container (uses SIGKILL)
  -l, --link      Remove the specified link
  -v, --volumes   Remove the volumes associated with the container
  • docker kill container
# 帮助
docker kill --help 

Usage:  docker kill [OPTIONS] CONTAINER [CONTAINER...]

Kill one or more running containers

Options:
  -s, --signal string   Signal to send to the container (default "KILL")
  • docker 在container中执行命令
# 帮助
docker exec --help 

Usage:  docker exec [OPTIONS] CONTAINER COMMAND [ARG...]

Run a command in a running container

Options:
  -d, --detach               Detached mode: run command in the background
      --detach-keys string   Override the key sequence for detaching a container
  -e, --env list             Set environment variables
  -i, --interactive          Keep STDIN open even if not attached
      --privileged           Give extended privileges to the command
  -t, --tty                  Allocate a pseudo-TTY
  -u, --user string          Username or UID (format: <name|uid>[:<group|gid>])
  -w, --workdir string       Working directory inside the container
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • docker常用命令详解 - CSDN博客 本文只记录docker命令在大部分情境下的使用,如果想了解每一个选项的...
    Meathill大魔王阅读 4,225评论 1 2
  • 本文只记录docker命令在大部分情境下的使用,如果想了解每一个选项的细节,请参考官方文档,这里只作为自己以后的备...
    Joncc阅读 1,904评论 0 0
  • Docker基础 这篇基础文章是方便用户在使用cSphere平台之前,了解docker基础知识。 针对已经有一定的...
    4ea0af17fd67阅读 3,203评论 0 0
  • 容器相关操作 docker create # 创建一个容器但是不启动它 docker run # 创建并启动一个容...
    蓝色的咖啡阅读 4,172评论 0 3
  • 绮蔓有罗(四) 绮罗睁眼的时候,发现自己躺在自己的房间里,林染正守在她身侧,看见她醒惊喜的唤着,“青衣,青衣,你家...
    疯草叶子阅读 2,981评论 0 2