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: [:])
  -w, --workdir string       Working directory inside the container

你可能感兴趣的:(docker常用命令)