Compartilhar via


Docker@0 – Tarefa do Docker v0

Crie, marque, envie por push, execute imagens do Docker ou execute um comando do Docker. Use essa tarefa com o Docker ou o Registro de Contêiner do Azure.

Observação

Docker@2 é uma versão mais recente dessa tarefa que simplifica a tarefa removendo entradas que podem ser passadas como argumentos para o comando .

Syntax

# 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.
# Docker v0
# Build, tag, push, or run Docker images, or run a Docker command. Task can be used with Docker or Azure Container registry.
- 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.

Entradas

containerregistrytype - Tipo de Registro de Contêiner
string. Obrigatórios. Valores Permitidos: Azure Container Registry e Container Registry. Valor padrão: Azure Container Registry.

Selecione 'Registro de Contêiner do Azure' para se conectar a ele usando uma Conexão de Serviço do Azure. Selecione 'Registro de contêiner' para se conectar a Docker Hub ou a qualquer outro registro de contêiner privado.


dockerRegistryConnection - Conexão do Serviço de Registro do Docker
Alias de entrada: dockerRegistryEndpoint. string. Opcional. Use quando containerregistrytype = Container Registry.

Especifica uma conexão de serviço do Registro do Docker. Obrigatório para comandos que precisam ser autenticados com um registro.


azureSubscription - Assinatura do Azure
Alias de entrada: azureSubscriptionEndpoint. string. Opcional. Use quando containerregistrytype = Azure Container Registry.

Especifica uma assinatura do Azure.


azureContainerRegistry - Registro de Contêiner do Azure
string. Opcional. Use quando containerregistrytype = Azure Container Registry.

Especifica um Registro de Contêiner do Azure na Assinatura do Azure selecionada. A imagem de contêiner é criada e enviada por push para esse registro de contêiner.


action - Ação
string. Obrigatórios. Valores permitidos: Build an image, Tag images, , Push an image, Push images, Run an image, Run a Docker command. Valor padrão: Build an image.

Especifica uma ação do Docker.


dockerFile - Arquivo do Docker
string. Obrigatório quando action = Build an image. Valor padrão: **/Dockerfile.

Especifica o caminho para o arquivo do Docker. A tarefa usa o primeiro arquivo do Docker encontrado para compilar a imagem.


addBaseImageData - Adicionar metadados de imagem base a imagens
boolean. Valor padrão: true.

O valor padrão adiciona dados de imagem base, como o nome da imagem base e o resumo para ajudar na rastreabilidade. Você pode recusar definindo o valor como false.


buildArguments - Argumentos de build
string. Opcional. Use quando action = Build an image.

Especifica variáveis de tempo de build para o arquivo do Docker. Formatar cada name=value par em uma nova linha.


defaultContext - Usar contexto de build padrão
boolean. Opcional. Use quando action = Build an image. Valor padrão: true.

Especifica o contexto de build do diretório que contém o arquivo do Docker.


context - Contexto de build
string. Opcional. Use quando action = Build an image && defaultContext = false.

Especifica o caminho para o contexto de build.


imageName - Nome da imagem
string. Obrigatório quando action == Build an image || action == Push an image || action == Run an image. Valor padrão: $(Build.Repository.Name):$(Build.BuildId).

Especifica o nome da imagem do Docker a ser criada, enviada por push ou executada.


imageNamesPath - Caminho de nomes de imagem
string. Obrigatório quando action == Tag images || action == Push images.

Especifica o caminho para um arquivo de texto que contém os nomes das imagens do Docker para marcar ou enviar por push. Liste cada nome de imagem em uma linha separada.


qualifyImageName - Qualificar Nome da Imagem
boolean. Opcional. Use quando action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Valor padrão: true.

Especifica um nome de imagem qualificado com o nome do host da conexão de serviço do Registro do Docker.


additionalImageTags - Marcas de imagem adicionais
string. Opcional. Use quando action = Build an image || action = Tag images || action = Push an image || action = Push images.

Especifica marcas adicionais para a imagem do Docker que está sendo criada ou enviada por push.


includeSourceTags - Incluir marcas de origem
boolean. Opcional. Use quando action = Build an image || action = Tag image || action = Push an image || action = Push images. Valor padrão: false.

Especifica se as marcas do Git devem ser incluídas ao criar ou enviar por push a imagem do Docker.


includeLatestTag - Incluir a marca mais recente
boolean. Opcional. Use quando action = Build an image || action = Push an image || action = Push images. Valor padrão: false.

Especifica se a marca mais recente deve ser incluída ao criar ou enviar por push a imagem do Docker.


imageDigestFile - Arquivo de Resumo de Imagem
string. Opcional. Use quando action = Push an image || action = Push images.

Especifica o caminho para um arquivo que é criado e preenchido com o resumo completo do repositório de imagens da imagem do Docker que foi enviada por push.


containerName - Nome do contêiner
string. Opcional. Use quando action = Run an image.

Especifica o nome do contêiner do Docker a ser executado.


ports - Portas
string. Opcional. Use quando action = Run an image.

Especifica portas no contêiner do Docker a serem publicadas no host. Liste cada host-port:container-port associação em uma nova linha.


volumes - Volumes
string. Opcional. Use quando action = Run an image.

Especifica os volumes a serem montados do host. Liste cada host-dir:container-dir uma em uma nova linha.


envVars - Variáveis de ambiente
string. Opcional. Use quando action = Run an image.

Especifica variáveis de ambiente para o contêiner do Docker. Liste cada name=value par em uma nova linha.


workDir - Diretório de Trabalho
string. Opcional. Use quando action = Run an image.

Especifica o diretório de trabalho para o contêiner do Docker.


entrypoint - Substituição de ponto de entrada
string. Opcional. Use quando action = Run an image.

Especifica uma substituição do ponto de entrada padrão para o contêiner do Docker.


containerCommand - Comando
string. Opcional. Use quando action = Run an image.

Especifica um comando de execução do Docker. O comando docker run primeiro cria uma camada de contêiner gravável sobre a imagem especificada e, em seguida, inicia-a usando o comando run especificado. Por exemplo, se a imagem contiver um aplicativo Web Python Flask simples, você poderá especificar python app.py para iniciar o aplicativo Web.


detached - Executar em segundo plano
boolean. Opcional. Use quando action = Run an image. Valor padrão: true.

Especifica se o contêiner do Docker deve ser executado em segundo plano.


restartPolicy - Política de Reinicialização
string. Obrigatório quando action = Run an image && detached = true. Valores permitidos: no, onFailure (Em caso de falha), always, unlessStopped (a menos que interrompido). Valor padrão: no.

Especifica uma política de reinicialização.


restartMaxRetries - Tentativas máximas de reinicialização
string. Opcional. Use quando action = Run an image && detached = true && restartPolicy = onFailure.

Especifica o número máximo de tentativas de reinicialização que o daemon do Docker tenta.


customCommand - Comando
string. Obrigatório quando action = Run a Docker command.

Especifica o comando e os argumentos do Docker a serem executados. Por exemplo, rmi -f image-name remove uma imagem.


dockerHostEndpoint - Conexão do Serviço de Host do Docker
string.

Especifica uma conexão de serviço de host do Docker. O padrão é o host do agente.


enforceDockerNamingConvention - Forçar o nome da imagem a seguir a convenção de nomenclatura do Docker
boolean. Valor padrão: true.

Se habilitado, modifica o nome da imagem do Docker de acordo com as convenções de nomenclatura do Docker. Por exemplo, converta caracteres maiúsculos em letras minúsculas e remova espaços.


workingDirectory - Diretório de Trabalho
Alias de entrada: cwd. string. Valor padrão: $(System.DefaultWorkingDirectory).

Especifica o diretório de trabalho para o comando do Docker.


memory - Limite de memória
string.

Especifica a quantidade máxima de memória disponível para o contêiner como um inteiro com sufixos opcionais, por exemplo 2GB.


Opções de controle da tarefa

Todas as tarefas têm opções de controle além de suas entradas de tarefa. Para obter mais informações, consulte Opções de controle e propriedades comuns da tarefa.

Variáveis de saída

Essa tarefa define as variáveis de saída a seguir, que você pode consumir em etapas downstream, trabalhos e estágios.

DockerOutput
Armazena a saída do comando docker.

DockerOutputPath
O caminho do arquivo que contém a saída do comando de build.

Essa tarefa define as variáveis de saída a seguir, que você pode consumir em etapas downstream, trabalhos e estágios.

DockerOutput
Armazena a saída do comando docker

Comentários

Docker@2 é uma versão mais recente dessa tarefa que simplifica a tarefa removendo entradas que podem ser passadas como argumentos para o comando .

Requisitos

Requisito Descrição
Tipos de pipeline YAML, build clássico, versão clássica
Executa em Agent, DeploymentGroup
Demandas Nenhum
Funcionalidades Essa tarefa não atende a nenhuma demanda para tarefas subsequentes no trabalho.
Restrições de comando Qualquer
Variáveis configuráveis Qualquer
Versão do agente Todas as versões do agente com suporte.
Categoria da tarefa Build

Confira também