美文网首页
Docker-容器管理常用命令

Docker-容器管理常用命令

作者: HelloTech | 来源:发表于2020-06-07 15:41 被阅读0次
  • 开启 Docker 实例
$ sudo systemctl start docker
  • 查看Docker所有的命令 : --help
$ docker --help

# 输出如下

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/root/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket(s) to connect to
  -l, --log-level string   Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
      --tls                Use TLS; implied by --tlsverify
      --tlscacert string   Trust certs signed only by this CA (default "/root/.docker/ca.pem")
      --tlscert string     Path to TLS certificate file (default "/root/.docker/cert.pem")
      --tlskey string      Path to TLS key file (default "/root/.docker/key.pem")
      --tlsverify          Use TLS and verify the remote
  -v, --version            Print version information and quit

Management Commands:
  builder     Manage builds
  config      Manage Docker configs
  container   Manage containers
  context     Manage contexts
  engine      Manage the docker engine
  image       Manage images
  network     Manage networks
  node        Manage Swarm nodes
  plugin      Manage plugins
  secret      Manage Docker secrets
  service     Manage services
  stack       Manage Docker stacks
  swarm       Manage Swarm
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  build       Build an image from a Dockerfile
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  images      List images
  import      Import the contents from a tarball to create a filesystem image
  info        Display system-wide information
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  login       Log in to a Docker registry
  logout      Log out from a Docker registry
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  ps          List containers
  pull        Pull an image or a repository from a registry
  push        Push an image or a repository to a registry
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  run         Run a command in a new container
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  search      Search the Docker Hub for images
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  version     Show the Docker version information
  wait        Block until one or more containers stop, then print their exit codes

Run 'docker COMMAND --help' for more information on a command.
  • 查看某个命令的使用方法
# 如 ps 命令使用方式
$ docker ps --help
# 输出
Usage:  docker ps [OPTIONS]

List containers

Options:
  -a, --all             Show all containers (default shows just running)
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print containers using a Go template
  -n, --last int        Show n last created containers (includes all states) (default -1)
  -l, --latest          Show the latest created container (includes all states)
      --no-trunc        Don't truncate output
  -q, --quiet           Only display numeric IDs
  -s, --size            Display total file sizes
  • 停止容器 : stop
$ docker stop 容器ID 或 容器名称
  • 开始容器 : start
$ docker start 容器ID 或者容器名称

注:
docker start 和 run 的区别:
run : 将镜像载入容器并且start,如果本地不存在该镜像会自动到docker hub查找并且下载

  • 进入容器: exec
$ docker exec -it 容器ID 执行的命令
  • 导出容器:export
# 导出本地某个容器
$ docker export 容器ID > path/自己命名的容器名称.tar
  • 导入容器快照:import
# 导入本地快照
$ cat path/容器快照  docker import - 镜像名称

# 导入远程快照
$ docker import http://domain/xxx.x 镜像名称
  • 查看容器内部的标准输出:logs
$ docker logs [options] 容器ID 或 容器名称

相关文章

  • Docker-容器管理常用命令

    开启 Docker 实例 查看Docker所有的命令 : --help 查看某个命令的使用方法 停止容器 : st...

  • 苹果软件集合(一)

    虚拟机 Docker- 开源的应用容器引擎。 DockStation- 管理 Docker 项目的程序。 Para...

  • docker.容器管理

    第三节.docker容器管理创建容器常用选项 管理容器常用命令 进入容器的俩种方法

  • docker使用

    安装docker linux centos 常用命令 容器管理

  • Docker命令大全

    docker 常用命令如下 管理命令: container 管理容器 image 管理镜像 netw...

  • Docker常用命令

    docker常用命令 命令介绍 管理命令: container 管理容器 image 管理镜像 netwo...

  • Docker常用命令

    常用命令: 镜像管理: 容器管理: docker build(docker build命令用于从Dockerfil...

  • Docker-容器

    应用程序打包生产镜像后,上传到Docker仓库,再从Docker仓库将镜像下载到本地,以镜像为模板可以创建容器,容...

  • Docker-容器

    Centos-Docker最佳安装方案 Centos-Docker最佳安装方案2 VM-Ubuntu安装方法 Do...

  • docker-容器

    1.制作镜像 2.查看镜像 3.查看启动的容器 4.容器镜像起一个完整的名字 5.上传镜像到docker hub ...

网友评论

      本文标题:Docker-容器管理常用命令

      本文链接:https://www.haomeiwen.com/subject/zksbzhtx.html