Docker命令行

本文详细介绍了Docker的各种命令行接口,包括EngineCLI、ComposeCLI、MachineCLI等,以及Docker的基本语法、核心命令如run、exec、ps等的使用方法,还有镜像管理和操作的相关说明。
摘要由CSDN通过智能技术生成

一、Docker命令行接口类型

引擎命令行接口(Engine CLI):Docker主要命令,包含docker和dockerd命令。

容器编排命令行接口(Compose CLI):Docker Compose 提供的,让用户构建并运行多容器应用。

机器命令行接口(Machine CLI):用来配置和管理远程docker主机。

DTR命令行接口:部署管理DOCKER可信注册中心。

UCP命令行接口:部署和管理通用面板(universal control panel)

二、docker基本语法

基本语法结构:

        docker [选项]  命令

1、选项短格式和长格式

短格式:一个连字符(-) 加上单字符,如:-d   -v   -i 等

长格式:两个连字符(--)加上字符串,如:--deamon   --version等

上面的选项中:

-d选项:docker容器在后台以守护态形式运行。

-i选项:让容器的标准输入保持打开

-t选项:让docker分配一个伪终端并绑定到容器的标准输入上。

2、短格式的单字符选项可以组合在一起使用

3、多值选项

多值选项(如-a=[])可以在单个命令行中多次定义。

4、登录容器

通过 exec 命令可以登录容器内部。

5、删除容器

一般要删除容器,应先停止容器,再用rm进行删除。

三、docker命令

  run         Create and run a new container from an image   创建运行一个新容器

  exec        Execute a command in a running container  在运行的容器中执行命令

  ps          List containers     查看容器列表

  build       Build an image from a Dockerfile  基于dockerfile文件构建镜像

  pull        Download an image from a registry  从仓库拉取镜像

  push        Upload an image to a registry  上传镜像到仓库

  images      List images  查看镜像列表

  login       Log in to a registry  登录仓库

  logout      Log out from a registry  退出登录

  search      Search Docker Hub for images  搜索镜像

  version     Show the Docker version information  显示版本信息

  info        Display system-wide information  显示系统信息

  Management Commands:    管理命令

  builder     Manage builds       管构建

  buildx*     Docker Buildx (Docker Inc., v0.12.1)  

  compose*    Docker Compose (Docker Inc., v2.24.5)  容器编排

  container   Manage containers  管理容器

  context     Manage contexts   管理上下文环境

  image       Manage images   管理镜像

  manifest    Manage Docker image manifests and manifest lists  

  network     Manage networks 管理网络

  plugin      Manage plugins    管理插件

  system      Manage Docker   管理docker

  trust       Manage trust on Docker images   管理docker镜像信任

  volume      Manage volumes   管理卷

  等等

四、镜像列表查看

最基本的查看镜像方法可以使用docker images   或者  docker image ls。

镜像列表查看语法:

[root@docker 001~]# docker images -h

Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]     # 使用语法

List images    

Aliases:   # 关联的命令

  docker image ls, docker image list, docker images     # 这三个命令效果等效

Options:

  -a, --all             Show all images (default hides intermediate images)

               # 显示所有镜像(默认会隐藏中间镜像)

      --digests         Show digests     # 显示镜像摘要值

  -f, --filter filter   Filter output based on conditions provided    # 筛选镜像

      --format string   Format output using a custom template:    # 格式化输出

                        'table':            Print output in table format

                        with column headers (default)

                        'table TEMPLATE':   Print output in table format

                        using the given Go template

                        'json':             Print in JSON format

                        'TEMPLATE':         Print output using the given

                        Go template.

                        Refer to https://docs.docker.com/go/formatting/

                        for more information about formatting output with

                        templates

      --no-trunc        Don't truncate output     # 不截断输出

  -q, --quiet           Only show image IDs        # 只显示镜像ID

  • 13
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值