Share via


Docker@0 - Docker v0, tâche

Générez, étiquetez, envoyez (push), exécutez des images Docker ou exécutez une commande Docker. Utilisez cette tâche avec Docker ou le registre de conteneurs Azure.

Notes

Docker@2 est une version plus récente de cette tâche qui simplifie la tâche en supprimant les entrées qui peuvent être passées en tant qu’arguments à la commande.

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.

Entrées

containerregistrytype - Type de registre de conteneurs
string. Obligatoire. Valeurs autorisées : Azure Container Registry, Container Registry. Valeur par défaut : Azure Container Registry.

Sélectionnez « Azure Container Registry » pour vous y connecter à l’aide d’une connexion de service Azure. Sélectionnez « Registre de conteneurs » pour vous connecter à Docker Hub ou à tout autre registre de conteneurs privé.


dockerRegistryConnection - Connexion au service Docker Registry
Alias d’entrée : dockerRegistryEndpoint. string. facultatif. Utilisez quand containerregistrytype = Container Registry.

Spécifie une connexion au service de registre Docker. Obligatoire pour les commandes qui doivent s’authentifier sur un registre.


azureSubscription - Abonnement Azure
Alias d’entrée : azureSubscriptionEndpoint. string. facultatif. Utilisez quand containerregistrytype = Azure Container Registry.

Spécifie un abonnement Azure.


azureContainerRegistry - Azure Container Registry
string. facultatif. Utilisez quand containerregistrytype = Azure Container Registry.

Spécifie un Azure Container Registry dans l’abonnement Azure sélectionné. L’image conteneur est générée, puis envoyée à ce registre de conteneurs.


action - Action
string. Obligatoire. Valeurs autorisées : Build an image, Tag images, Push an image, Run an imagePush imagesRun a Docker command. Valeur par défaut : Build an image.

Spécifie une action Docker.


dockerFile - Fichier Docker
string. Nécessaire lorsque action = Build an image. Valeur par défaut : **/Dockerfile.

Spécifie le chemin d’accès au fichier Docker. La tâche utilise le premier fichier Docker qu’elle trouve pour générer l’image.


addBaseImageData - Ajouter des métadonnées d’image de base à des images
boolean. Valeur par défaut : true.

La valeur par défaut ajoute des données d’image de base telles que le nom de l’image de base et le digest pour faciliter la traçabilité. Vous pouvez refuser en définissant la valeur sur false.


buildArguments - Arguments de génération
string. facultatif. Utilisez quand action = Build an image.

Spécifie des variables au moment de la génération pour le fichier Docker. Mettez en forme chaque name=value paire sur une nouvelle ligne.


defaultContext - Utiliser le contexte de build par défaut
boolean. facultatif. Utilisez quand action = Build an image. Valeur par défaut : true.

Spécifie le contexte de génération du répertoire qui contient le fichier Docker.


context - Contexte de build
string. facultatif. Utilisez quand action = Build an image && defaultContext = false.

Spécifie le chemin d’accès au contexte de génération.


imageName - Nom de l’image
string. Nécessaire lorsque action == Build an image || action == Push an image || action == Run an image. Valeur par défaut : $(Build.Repository.Name):$(Build.BuildId).

Spécifie le nom de l’image Docker à générer, envoyer (push) ou exécuter.


imageNamesPath - Chemin des noms d’image
string. Nécessaire lorsque action == Tag images || action == Push images.

Spécifie le chemin d’accès à un fichier texte qui contient les noms des images Docker à baliser ou envoyer (push). Répertoriez chaque nom d’image sur une ligne distincte.


qualifyImageName - Qualifier le nom de l’image
boolean. facultatif. Utilisez quand action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Valeur par défaut : true.

Spécifie un nom d’image éligible avec le nom d’hôte de la connexion au service de Registre Docker.


additionalImageTags - Balises d’image supplémentaires
string. facultatif. Utilisez quand action = Build an image || action = Tag images || action = Push an image || action = Push images.

Spécifie des balises supplémentaires pour l’image Docker en cours de génération ou d’envoi (push).


includeSourceTags - Inclure des étiquettes sources
boolean. facultatif. Utilisez quand action = Build an image || action = Tag image || action = Push an image || action = Push images. Valeur par défaut : false.

Spécifie s’il faut inclure des balises Git lors de la génération ou de l’envoi (push) de l’image Docker.


includeLatestTag - Inclure la dernière balise
boolean. facultatif. Utilisez quand action = Build an image || action = Push an image || action = Push images. Valeur par défaut : false.

Spécifie s’il faut inclure la dernière balise lors de la génération ou de l’envoi (push) de l’image Docker.


imageDigestFile - Fichier de synthèse d’image
string. facultatif. Utilisez quand action = Push an image || action = Push images.

Spécifie le chemin d’accès à un fichier créé et rempli avec le condensé complet du référentiel d’images de l’image Docker qui a été poussée.


containerName - Nom du conteneur
string. facultatif. Utilisez quand action = Run an image.

Spécifie le nom du conteneur Docker à exécuter.


ports - Ports
string. facultatif. Utilisez quand action = Run an image.

Spécifie les ports dans le conteneur Docker à publier sur l’hôte. Répertorier chaque host-port:container-port liaison sur une nouvelle ligne.


volumes - Volumes
string. facultatif. Utilisez quand action = Run an image.

Spécifie les volumes à monter à partir de l’hôte. Répertorier chacun host-dir:container-dir sur une nouvelle ligne.


envVars - Variables d’environnement
string. facultatif. Utilisez quand action = Run an image.

Spécifie des variables d’environnement pour le conteneur Docker. Répertorier chaque name=value paire sur une nouvelle ligne.


workDir - Répertoire de travail
string. facultatif. Utilisez quand action = Run an image.

Spécifie le répertoire de travail du conteneur Docker.


entrypoint - Remplacement du point d’entrée
string. facultatif. Utilisez quand action = Run an image.

Spécifie un remplacement du point d’entrée par défaut pour le conteneur Docker.


containerCommand - Commande
string. facultatif. Utilisez quand action = Run an image.

Spécifie une commande Docker run. La commande docker run crée d’abord une couche de conteneur accessible en écriture sur l’image spécifiée, puis la démarre à l’aide de la commande d’exécution spécifiée. Par exemple, si l’image contient une application web Python Flask simple, vous pouvez spécifier python app.py pour lancer l’application web.


detached - Exécuter en arrière-plan
boolean. facultatif. Utilisez quand action = Run an image. Valeur par défaut : true.

Spécifie s’il faut exécuter le conteneur Docker en arrière-plan.


restartPolicy - Stratégie de redémarrage
string. Nécessaire lorsque action = Run an image && detached = true. Valeurs autorisées : no, onFailure (En cas d’échec), always, unlessStopped (sauf si elles sont arrêtées). Valeur par défaut : no.

Spécifie une stratégie de redémarrage.


restartMaxRetries - Nombre maximal de tentatives de redémarrage
string. facultatif. Utilisez quand action = Run an image && detached = true && restartPolicy = onFailure.

Spécifie le nombre maximal de tentatives de redémarrage que le démon Docker tente.


customCommand - Commande
string. Nécessaire lorsque action = Run a Docker command.

Spécifie la commande Docker et les arguments à exécuter. Par exemple, rmi -f image-name supprime une image.


dockerHostEndpoint - Connexion au service hôte Docker
string.

Spécifie une connexion de service hôte Docker. La valeur par défaut est l’hôte de l’agent.


enforceDockerNamingConvention - Forcer le nom de l’image à suivre la convention d’affectation de noms Docker
boolean. Valeur par défaut : true.

Si cette option est activée, modifie le nom de l’image Docker en fonction des conventions d’affectation de noms Docker. Par exemple, convertissez les caractères majuscules en minuscules et supprimez les espaces.


workingDirectory - Répertoire de travail
Alias d’entrée : cwd. string. Valeur par défaut : $(System.DefaultWorkingDirectory).

Spécifie le répertoire de travail de la commande Docker.


memory - Limite de mémoire
string.

Spécifie la quantité maximale de mémoire disponible pour le conteneur sous la forme d’un entier avec des suffixes facultatifs, par exemple 2GB.


Options de contrôle de la tâche

Toutes les tâches ont des options de contrôle en plus de leurs entrées de tâches. Pour plus d’informations, consultez Options de contrôle et propriétés de tâche courantes.

Variables de sortie

Cette tâche définit les variables de sortie suivantes, que vous pouvez utiliser dans les étapes, les travaux et les étapes en aval.

DockerOutput
Stocke la sortie de la commande docker.

DockerOutputPath
Chemin d’accès du fichier qui contient la sortie de la commande build.

Cette tâche définit les variables de sortie suivantes, que vous pouvez utiliser dans les étapes, les travaux et les étapes en aval.

DockerOutput
Stocke la sortie de la commande docker

Remarques

Docker@2 est une version plus récente de cette tâche qui simplifie la tâche en supprimant les entrées qui peuvent être passées en tant qu’arguments à la commande.

Configuration requise

Condition requise Description
Types de pipelines YAML, build classique, version classique
S’exécute sur Agent, DeploymentGroup
Demandes None
Capabilities Cette tâche ne répond à aucune demande pour les tâches suivantes dans le travail.
Restrictions de commande Quelconque
Variables paramétrables Quelconque
Version de l’agent Toutes les versions d’agent prises en charge.
Catégorie de la tâche Build

Voir aussi