Docker@0 - Docker v0 任务

生成、标记、推送、运行 Docker 映像或运行 Docker 命令。 将此任务与 Docker 或 Azure 容器注册表配合使用。

注释

Docker@2 是此任务的较新版本,它通过删除可作为参数传递给命令的输入来简化任务。

生成、标记、推送、运行 Docker 映像或运行 Docker 命令。 将此任务与 Docker 或 Azure 容器注册表配合使用。

注释

Docker@2 是此任务的较新版本,它通过删除可作为参数传递给命令的输入来简化任务。

语法

# Docker v0
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@0
  inputs:
    containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required. Container Registry Type. Default: Azure Container Registry.
    #dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. Optional. Use when containerregistrytype = Container Registry. Docker Registry Service Connection. 
    #azureSubscription: # string. Alias: azureSubscriptionEndpoint. Optional. Use when containerregistrytype = Azure Container Registry. Azure subscription. 
    #azureContainerRegistry: # string. Optional. Use when containerregistrytype = Azure Container Registry. Azure Container Registry. 
    action: 'Build an image' # 'Build an image' | 'Tag images' | 'Push an image' | 'Push images' | 'Run an image' | 'Run a Docker command'. Required. Action. Default: Build an image.
    #dockerFile: '**/Dockerfile' # string. Required when action = Build an image. Docker File. Default: **/Dockerfile.
    #buildArguments: # string. Optional. Use when action = Build an image. Build Arguments. 
    #defaultContext: true # boolean. Optional. Use when action = Build an image. Use Default Build Context. Default: true.
    #context: # string. Optional. Use when action = Build an image && defaultContext = false. Build Context. 
    #imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when action == Build an image || action == Push an image || action == Run an image. Image Name. Default: $(Build.Repository.Name):$(Build.BuildId).
    #imageNamesPath: # string. Required when action == Tag images || action == Push images. Image Names Path. 
    #qualifyImageName: true # boolean. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Qualify Image Name. Default: true.
    #additionalImageTags: # string. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images. Additional Image Tags. 
    #includeSourceTags: false # boolean. Optional. Use when action = Build an image || action = Tag image || action = Push an image || action = Push images. Include Source Tags. Default: false.
    #includeLatestTag: false # boolean. Optional. Use when action = Build an image || action = Push an image || action = Push images. Include Latest Tag. Default: false.
    #imageDigestFile: # string. Optional. Use when action = Push an image || action = Push images. Image Digest File. 
    #containerName: # string. Optional. Use when action = Run an image. Container Name. 
    #ports: # string. Optional. Use when action = Run an image. Ports. 
    #volumes: # string. Optional. Use when action = Run an image. Volumes. 
    #envVars: # string. Optional. Use when action = Run an image. Environment Variables. 
    #workDir: # string. Optional. Use when action = Run an image. Working Directory. 
    #entrypoint: # string. Optional. Use when action = Run an image. Entry Point Override. 
    #containerCommand: # string. Optional. Use when action = Run an image. Command. 
    #detached: true # boolean. Optional. Use when action = Run an image. Run In Background. Default: true.
    #restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when action = Run an image && detached = true. Restart Policy. Default: no.
    #restartMaxRetries: # string. Optional. Use when action = Run an image && detached = true && restartPolicy = onFailure. Maximum Restart Retries. 
    #customCommand: # string. Required when action = Run a Docker command. Command. 
  # commands
    #addBaseImageData: true # boolean. Add base image metadata to image(s). Default: true.
  # Advanced Options
    #dockerHostEndpoint: # string. Docker Host Service Connection. 
    #enforceDockerNamingConvention: true # boolean. Force image name to follow Docker naming convention. Default: true.
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working Directory. Default: $(System.DefaultWorkingDirectory).
    #memory: # string. Memory limit.
# Docker v0
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@0
  inputs:
    containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required. Container Registry Type. Default: Azure Container Registry.
    #dockerRegistryConnection: # string. Alias: dockerRegistryEndpoint. Optional. Use when containerregistrytype = Container Registry. Docker Registry Service Connection. 
    #azureSubscription: # string. Alias: azureSubscriptionEndpoint. Optional. Use when containerregistrytype = Azure Container Registry. Azure subscription. 
    #azureContainerRegistry: # string. Optional. Use when containerregistrytype = Azure Container Registry. Azure Container Registry. 
    action: 'Build an image' # 'Build an image' | 'Tag images' | 'Push an image' | 'Push images' | 'Run an image' | 'Run a Docker command'. Required. Action. Default: Build an image.
    #dockerFile: '**/Dockerfile' # string. Required when action = Build an image. Docker File. Default: **/Dockerfile.
    #buildArguments: # string. Optional. Use when action = Build an image. Build Arguments. 
    #defaultContext: true # boolean. Optional. Use when action = Build an image. Use Default Build Context. Default: true.
    #context: # string. Optional. Use when action = Build an image && defaultContext = false. Build Context. 
    #imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when action == Build an image || action == Push an image || action == Run an image. Image Name. Default: $(Build.Repository.Name):$(Build.BuildId).
    #imageNamesPath: # string. Required when action == Tag images || action == Push images. Image Names Path. 
    #qualifyImageName: true # boolean. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Qualify Image Name. Default: true.
    #additionalImageTags: # string. Optional. Use when action = Build an image || action = Tag images || action = Push an image || action = Push images. Additional Image Tags. 
    #includeSourceTags: false # boolean. Optional. Use when action = Build an image || action = Tag image || action = Push an image || action = Push images. Include Source Tags. Default: false.
    #includeLatestTag: false # boolean. Optional. Use when action = Build an image || action = Push an image || action = Push images. Include Latest Tag. Default: false.
    #imageDigestFile: # string. Optional. Use when action = Push an image || action = Push images. Image Digest File. 
    #containerName: # string. Optional. Use when action = Run an image. Container Name. 
    #ports: # string. Optional. Use when action = Run an image. Ports. 
    #volumes: # string. Optional. Use when action = Run an image. Volumes. 
    #envVars: # string. Optional. Use when action = Run an image. Environment Variables. 
    #workDir: # string. Optional. Use when action = Run an image. Working Directory. 
    #entrypoint: # string. Optional. Use when action = Run an image. Entry Point Override. 
    #containerCommand: # string. Optional. Use when action = Run an image. Command. 
    #detached: true # boolean. Optional. Use when action = Run an image. Run In Background. Default: true.
    #restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when action = Run an image && detached = true. Restart Policy. Default: no.
    #restartMaxRetries: # string. Optional. Use when action = Run an image && detached = true && restartPolicy = onFailure. Maximum Restart Retries. 
    #customCommand: # string. Required when action = Run a Docker command. Command. 
  # Advanced Options
    #dockerHostEndpoint: # string. Docker Host Service Connection. 
    #enforceDockerNamingConvention: true # boolean. Force image name to follow Docker naming convention. Default: true.
    #workingDirectory: '$(System.DefaultWorkingDirectory)' # string. Alias: cwd. Working Directory. Default: $(System.DefaultWorkingDirectory).
    #memory: # string. Memory limit.

输入

containerregistrytype - 容器注册表类型
string。 必填。 允许的值:Azure Container RegistryContainer Registry。 默认值:Azure Container Registry

选择“Azure 容器注册表”以使用 Azure 服务连接连接到它。 选择“容器注册表”以连接到 Docker 中心或任何其他专用容器注册表。


dockerRegistryConnection - Docker 注册表服务连接
输入别名dockerRegistryEndpoint. string。 可选。 当 containerregistrytype = Container Registry时使用。

指定 Docker 注册表服务连接。 需要使用注册表进行身份验证的命令。


azureSubscription - Azure 订阅
输入别名azureSubscriptionEndpoint. string。 可选。 当 containerregistrytype = Azure Container Registry时使用。

指定 Azure 订阅。


azureContainerRegistry - Azure 容器注册表
string。 可选。 当 containerregistrytype = Azure Container Registry时使用。

指定所选 Azure 订阅中的 Azure 容器注册表。 生成容器映像,然后将其推送到此容器注册表。


action - 操作
string。 必填。 允许的值:Build an imageTag imagesPush an imagePush imagesRun an imageRun a Docker command。 默认值:Build an image

指定 Docker作。


dockerFile - Docker 文件
stringaction = Build an image时是必需的。 默认值:**/Dockerfile

指定 Docker 文件的路径。 该任务使用它找到的第一个 Docker 文件来生成映像。


addBaseImageData - 向图像添加基础映像元数据
boolean。 默认值:true

默认值添加基础映像数据,例如基础映像名称和摘要,以帮助实现可跟踪性。 可以通过将值设置为 false来选择退出。


buildArguments - 生成参数
string。 可选。 当 action = Build an image时使用。

指定 Docker 文件的生成时变量。 在新行上设置每个 name=value 对的格式。


defaultContext - 使用默认生成上下文
boolean。 可选。 当 action = Build an image时使用。 默认值:true

指定包含 Docker 文件的目录的生成上下文。


context - 生成上下文
string。 可选。 当 action = Build an image && defaultContext = false时使用。

指定生成上下文的路径。


imageName - 映像名称
stringaction == Build an image || action == Push an image || action == Run an image时是必需的。 默认值:$(Build.Repository.Name):$(Build.BuildId)

指定要生成、推送或运行的 Docker 映像的名称。


imageNamesPath - 映像名称路径
stringaction == Tag images || action == Push images时是必需的。

指定要标记或推送的 Docker 映像的名称的文本文件的路径。 列出单独的行中的每个图像名称。


qualifyImageName - 限定映像名称
boolean。 可选。 当 action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image时使用。 默认值:true

使用 Docker 注册表服务连接的主机名指定限定映像名称。


additionalImageTags - 其他图像标记
string。 可选。 当 action = Build an image || action = Tag images || action = Push an image || action = Push images时使用。

指定正在生成或推送的 Docker 映像的其他标记。


includeSourceTags - 包括源标记
boolean。 可选。 当 action = Build an image || action = Tag image || action = Push an image || action = Push images时使用。 默认值:false

指定在生成或推送 Docker 映像时是否包含 Git 标记。


includeLatestTag - 包括最新标记
boolean。 可选。 当 action = Build an image || action = Push an image || action = Push images时使用。 默认值:false

指定在生成或推送 Docker 映像时是否包括 最新的 标记。


imageDigestFile - 图像摘要文件
string。 可选。 当 action = Push an image || action = Push images时使用。

指定创建并填充已推送的 Docker 映像的完整映像存储库摘要的文件的路径。


containerName - 容器名称
string。 可选。 当 action = Run an image时使用。

指定要运行的 Docker 容器的名称。


ports - 端口
string。 可选。 当 action = Run an image时使用。

指定要发布到主机的 Docker 容器中的端口。 列出新行上的每个 host-port:container-port 绑定。


volumes -
string。 可选。 当 action = Run an image时使用。

指定要从主机装载的卷。 列出新行上的每个 host-dir:container-dir


envVars - 环境变量
string。 可选。 当 action = Run an image时使用。

指定 Docker 容器的环境变量。 列出新行上的每个 name=value 对。


workDir - 工作目录
string。 可选。 当 action = Run an image时使用。

指定 Docker 容器的工作目录。


entrypoint - 入口点替代
string。 可选。 当 action = Run an image时使用。

指定 Docker 容器的默认入口点的替代。


containerCommand - 命令
string。 可选。 当 action = Run an image时使用。

指定 Docker 运行命令。 docker run 命令首先在指定的映像上创建可写容器层,然后使用指定的运行命令启动它。 例如,如果映像包含简单的 Python Flask Web 应用程序,则可以指定要启动 Web 应用程序的 python app.py


在后台中运行 detached -
boolean。 可选。 当 action = Run an image时使用。 默认值:true

指定是否在后台运行 Docker 容器。


restartPolicy - 重启策略
stringaction = Run an image && detached = true时是必需的。 允许的值:noonFailure(失败时)、alwaysunlessStopped(除非停止)。 默认值:no

指定重启策略。


restartMaxRetries - 最大重启重试次数
string。 可选。 当 action = Run an image && detached = true && restartPolicy = onFailure时使用。

指定 Docker 守护程序尝试的最大重启重试次数。


customCommand - 命令
stringaction = Run a Docker command时是必需的。

指定要执行的 Docker 命令和参数。 例如,rmi -f image-name 删除映像。


dockerHostEndpoint - Docker 托管服务连接
string

指定 Docker 主机服务连接。 默认为代理的主机。


enforceDockerNamingConvention - 强制映像名称遵循 Docker 命名约定
boolean。 默认值:true

如果启用,则根据 Docker 命名约定修改 Docker 映像名称。 例如,将大写字符转换为小写并删除空格。


workingDirectory - 工作目录
输入别名cwd. string。 默认值:$(System.DefaultWorkingDirectory)

指定 Docker 命令的工作目录。


memory - 内存限制
string

指定容器可用的最大内存量作为具有可选后缀的整数,例如 2GB


任务控制选项

除任务输入之外,所有任务都具有控制选项。 有关详细信息,请参阅 控件选项和常见任务属性

输出变量

此任务定义以下 输出变量,可以在下游步骤、作业和阶段中使用。

DockerOutput
存储 docker 命令的输出。

DockerOutputPath
包含生成命令输出的文件的路径。

此任务定义以下 输出变量,可以在下游步骤、作业和阶段中使用。

DockerOutput
存储 docker 命令的输出

注解

Docker@2 是此任务的较新版本,它通过删除可作为参数传递给命令的输入来简化任务。

要求

要求 说明
管道类型 YAML,经典版本,经典版本
运行时间 代理,DeploymentGroup
需求 没有
功能 此任务不满足作业中后续任务的任何要求。
命令限制 任何
Settable 变量 任何
代理版本 所有支持的代理版本。
任务类别 建造

另请参阅