Docker@1 - Docker v1-taak
Bouw, tag, push of voer Docker-installatiekopieën uit of voer een Docker-opdracht uit. Gebruik deze taak met Docker of het Azure Container Registry.
Notitie
Docker@2 is een nieuwere versie van deze taak die de taak vereenvoudigt door invoer te verwijderen die als argumenten aan de opdracht kunnen worden doorgegeven.
Syntaxis
# Docker v1
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@1
inputs:
# Container Registry
#containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required when command != logout. Container registry type. Default: Azure Container Registry.
#dockerRegistryEndpoint: # string. Optional. Use when containerregistrytype = Container Registry && command != logout. Docker registry service connection.
#azureSubscriptionEndpoint: # string. Optional. Use when containerregistrytype = Azure Container Registry && command != logout. Azure subscription.
#azureContainerRegistry: # string. Optional. Use when containerregistrytype = Azure Container Registry && command != logout. Azure container registry.
# Commands
#addBaseImageData: true # boolean. Add base image metadata to image(s). Default: true.
command: 'Build an image' # 'Build an image' | 'Tag image' | 'Push an image' | 'Run an image' | 'login' | 'logout'. Required. Command. Default: Build an image.
#dockerFile: '**/Dockerfile' # string. Required when command = Build an image || command = build. Dockerfile. Default: **/Dockerfile.
#arguments: # string. Optional. Use when command != login && command != logout. Arguments.
#pushMultipleImages: false # boolean. Optional. Use when command = Push an image || command = push. Push multiple images. Default: false.
#tagMultipleImages: false # boolean. Optional. Use when command = Tag image || command = tag. Tag multiple images. Default: false.
#imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when command = Build an image || command = build || command = Run an image || command = run || pushMultipleImages = false || tagMultipleImages = false. Image name. Default: $(Build.Repository.Name):$(Build.BuildId).
#imageNamesPath: # string. Required when tagMultipleImages = true || pushMultipleImages = true. Image names path.
#qualifyImageName: true # boolean. Optional. Use when command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push || command = Run an image || command = run. Qualify image name. Default: true.
#qualifySourceImageName: false # boolean. Optional. Use when command = Tag image || command = tag. Qualify source image name. Default: false.
#includeSourceTags: false # boolean. Optional. Use when command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push. Include source tags. Default: false.
#includeLatestTag: false # boolean. Optional. Use when command = Build an image || command = build. Include latest tag. Default: false.
#addDefaultLabels: true # boolean. Optional. Use when addDefaultLabels = false. Add default labels. Default: true.
#useDefaultContext: true # boolean. Optional. Use when command = Build an image || command = build. Use default build context. Default: true.
#buildContext: # string. Optional. Use when useDefaultContext = false. Build context.
#imageDigestFile: # string. Optional. Use when command = Push an image || command = push. Image digest file.
#containerName: # string. Optional. Use when command = Run an image || command = run. Container name.
#ports: # string. Optional. Use when command = Run an image || command = run. Ports.
#volumes: # string. Optional. Use when command = Run an image || command = run. Volumes.
#envVars: # string. Optional. Use when command = Run an image || command = run. Environment variables.
#workingDirectory: # string. Optional. Use when command = Run an image || command = run. Working directory.
#entrypointOverride: # string. Optional. Use when command = Run an image || command = run. Entry point override.
#containerCommand: # string. Optional. Use when command = Run an image || command = run. Container command.
#runInBackground: true # boolean. Optional. Use when command = Run an image || command = run. Run in background. Default: true.
restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when runInBackground = true. Restart policy. Default: no.
#maxRestartRetries: # string. Optional. Use when runInBackground = true && restartPolicy = onFailure. Maximum restart retries.
# Advanced Options
#dockerHostEndpoint: # string. Optional. Use when command != login && command != logout. Docker host service connection.
#enforceDockerNamingConvention: true # boolean. Optional. Use when command != login && command != logout. Force image name to follow Docker naming convention. Default: true.
#memoryLimit: # string. Optional. Use when command != login && command != logout. Memory limit.
# Docker v1
# Build, tag, push, or run Docker images, or run a Docker command.
- task: Docker@1
inputs:
# Container Registry
#containerregistrytype: 'Azure Container Registry' # 'Azure Container Registry' | 'Container Registry'. Required when command != logout. Container registry type. Default: Azure Container Registry.
#dockerRegistryEndpoint: # string. Optional. Use when containerregistrytype = Container Registry && command != logout. Docker registry service connection.
#azureSubscriptionEndpoint: # string. Optional. Use when containerregistrytype = Azure Container Registry && command != logout. Azure subscription.
#azureContainerRegistry: # string. Optional. Use when containerregistrytype = Azure Container Registry && command != logout. Azure container registry.
# Commands
command: 'Build an image' # 'Build an image' | 'Tag image' | 'Push an image' | 'Run an image' | 'login' | 'logout'. Required. Command. Default: Build an image.
#dockerFile: '**/Dockerfile' # string. Required when command = Build an image || command = build. Dockerfile. Default: **/Dockerfile.
#arguments: # string. Optional. Use when command != login && command != logout. Arguments.
#pushMultipleImages: false # boolean. Optional. Use when command = Push an image || command = push. Push multiple images. Default: false.
#tagMultipleImages: false # boolean. Optional. Use when command = Tag image || command = tag. Tag multiple images. Default: false.
#imageName: '$(Build.Repository.Name):$(Build.BuildId)' # string. Required when command = Build an image || command = build || command = Run an image || command = run || pushMultipleImages = false || tagMultipleImages = false. Image name. Default: $(Build.Repository.Name):$(Build.BuildId).
#imageNamesPath: # string. Required when tagMultipleImages = true || pushMultipleImages = true. Image names path.
#qualifyImageName: true # boolean. Optional. Use when command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push || command = Run an image || command = run. Qualify image name. Default: true.
#qualifySourceImageName: false # boolean. Optional. Use when command = Tag image || command = tag. Qualify source image name. Default: false.
#includeSourceTags: false # boolean. Optional. Use when command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push. Include source tags. Default: false.
#includeLatestTag: false # boolean. Optional. Use when command = Build an image || command = build. Include latest tag. Default: false.
#addDefaultLabels: true # boolean. Optional. Use when addDefaultLabels = false. Add default labels. Default: true.
#useDefaultContext: true # boolean. Optional. Use when command = Build an image || command = build. Use default build context. Default: true.
#buildContext: # string. Optional. Use when useDefaultContext = false. Build context.
#imageDigestFile: # string. Optional. Use when command = Push an image || command = push. Image digest file.
#containerName: # string. Optional. Use when command = Run an image || command = run. Container name.
#ports: # string. Optional. Use when command = Run an image || command = run. Ports.
#volumes: # string. Optional. Use when command = Run an image || command = run. Volumes.
#envVars: # string. Optional. Use when command = Run an image || command = run. Environment variables.
#workingDirectory: # string. Optional. Use when command = Run an image || command = run. Working directory.
#entrypointOverride: # string. Optional. Use when command = Run an image || command = run. Entry point override.
#containerCommand: # string. Optional. Use when command = Run an image || command = run. Container command.
#runInBackground: true # boolean. Optional. Use when command = Run an image || command = run. Run in background. Default: true.
restartPolicy: 'no' # 'no' | 'onFailure' | 'always' | 'unlessStopped'. Required when runInBackground = true. Restart policy. Default: no.
#maxRestartRetries: # string. Optional. Use when runInBackground = true && restartPolicy = onFailure. Maximum restart retries.
# Advanced Options
#dockerHostEndpoint: # string. Optional. Use when command != login && command != logout. Docker host service connection.
#enforceDockerNamingConvention: true # boolean. Optional. Use when command != login && command != logout. Force image name to follow Docker naming convention. Default: true.
#memoryLimit: # string. Optional. Use when command != login && command != logout. Memory limit.
Invoer
containerregistrytype
-
containerregistertype
string
. Vereist wanneer command != logout
. Toegestane waarden: Azure Container Registry
, Container Registry
. Standaardwaarde: Azure Container Registry
.
Hiermee geeft u het Azure Container Registry op om verbinding te maken met behulp van een Azure-serviceverbinding. Selecteer een Azure Container Registry om verbinding te maken met een Docker Hub of een ander privécontainerregister.
addBaseImageData
-
Metagegevens van basisinstallatiekopieën toevoegen aan
boolean
. Standaardwaarde: true
.
Met de standaardwaarde worden basisafbeeldingsgegevens, zoals de naam en samenvatting van de basisinstallatiekopieën, toegevoegd om te helpen bij tracering. U kunt zich afmelden voor dit standaardgedrag door deze waarde in te stellen op false
.
dockerRegistryEndpoint
-
docker-registerserviceverbinding
string
. Facultatief. Gebruiken wanneer containerregistrytype = Container Registry && command != logout
.
Hiermee geeft u een Docker-registerserviceverbinding op. Vereist voor opdrachten die worden geverifieerd met behulp van een register.
azureSubscriptionEndpoint
-
Azure-abonnement
string
. Facultatief. Gebruiken wanneer containerregistrytype = Azure Container Registry && command != logout
.
Hiermee geeft u een Azure-abonnement op.
azureContainerRegistry
-
Azure-containerregister
string
. Facultatief. Gebruiken wanneer containerregistrytype = Azure Container Registry && command != logout
.
Hiermee geeft u een Azure Container Registry in het geselecteerde Azure-abonnement op. De containerinstallatiekopie wordt gebouwd en naar dit containerregister gepusht.
command
-
opdracht
string
. Verplicht. Toegestane waarden: Build an image
(build), Tag image
(tag), Push an image
(push), Run an image
(uitvoeren), login
, logout
. Standaardwaarde: Build an image
.
Hiermee geeft u de docker-opdracht die moet worden uitgevoerd.
dockerFile
-
Dockerfile-
string
. Vereist wanneer command = Build an image || command = build
. Standaardwaarde: **/Dockerfile
.
Hiermee geeft u het pad naar het Docker-bestand. De taak maakt gebruik van het eerste Docker-bestand dat wordt gevonden om de installatiekopieën te bouwen.
arguments
-
argumenten
string
. Facultatief. Gebruiken wanneer command != login && command != logout
.
Hiermee geeft u aanvullende argumenten op die moeten worden doorgegeven aan de docker-client. Als u de waarde buildAndPush
in de opdrachtparameter gebruikt, wordt de eigenschap argumenten genegeerd.
pushMultipleImages
-
meerdere installatiekopieën pushen
boolean
. Facultatief. Gebruiken wanneer command = Push an image || command = push
. Standaardwaarde: false
.
Hiermee geeft u een lijst in een tekstbestand van Docker-installatiekopieën die moeten worden gepusht. Geef elke afbeeldingsnaam op in de indeling Imagename1:tag1
op een afzonderlijke regel. Een afbeeldingsnaam zonder tags weergeven, bijvoorbeeld Imagename2
, pusht alle tags in de Imagename2
container.
tagMultipleImages
-
meerdere afbeeldingen taggen
boolean
. Facultatief. Gebruiken wanneer command = Tag image || command = tag
. Standaardwaarde: false
.
Hiermee geeft u een lijst met meerdere installatiekopieën en Docker-installatiekopieën op die moeten worden gelabeld in een tekstbestand. Geef elke afbeeldingsnaam op in de indeling Imagename1:tag1
op een afzonderlijke regel. Afbeeldingen die worden vermeld zonder tag als Imagename2
worden standaard gelabeld als meest recente.
imageName
-
naam van installatiekopieën
string
. Vereist wanneer command = Build an image || command = build || command = Run an image || command = run || pushMultipleImages = false || tagMultipleImages = false
. Standaardwaarde: $(Build.Repository.Name):$(Build.BuildId)
.
Hiermee geeft u de naam van de Docker-installatiekopieën op die moeten worden gebouwd, gepusht of uitgevoerd.
imageNamesPath
-
pad naar afbeeldingsnamen
string
. Vereist wanneer tagMultipleImages = true || pushMultipleImages = true
.
Hiermee geeft u het pad naar een tekstbestand dat de namen van de Docker-installatiekopieën bevat die moeten worden gelabeld of gepusht. Geef elke naam van de installatiekopie op een afzonderlijke regel weer.
qualifyImageName
-
naam van installatiekopieën kwalificeren
boolean
. Facultatief. Gebruiken wanneer command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push || command = Run an image || command = run
. Standaardwaarde: true
.
Hiermee geeft u een in aanmerking komende installatiekopienaam op met de hostnaam van de Docker-registerserviceverbinding.
qualifySourceImageName
-
naam van broninstallatiekopieën kwalificeren
boolean
. Facultatief. Gebruiken wanneer command = Tag image || command = tag
. Standaardwaarde: false
.
Hiermee geeft u een in aanmerking komende installatiekopienaam op met de hostnaam van de Docker-registerserviceverbinding.
includeSourceTags
-
brontags opnemen
boolean
. Facultatief. Gebruiken wanneer command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push
. Standaardwaarde: false
.
Hiermee geeft u Git-tags op die moeten worden opgenomen bij het bouwen of pushen van de Docker-installatiekopieën.
includeLatestTag
-
Meest recente tag opnemen
boolean
. Facultatief. Gebruiken wanneer command = Build an image || command = build
. Standaardwaarde: false
.
Hiermee geeft u op of de meest recente-tag moet worden gebruikt bij het bouwen van de Docker-installatiekopieën.
addDefaultLabels
-
standaardlabels toevoegen
boolean
. Facultatief. Gebruiken wanneer addDefaultLabels = false
. Standaardwaarde: true
.
Hiermee geeft u op of CI/CD-metagegevens moeten worden toegevoegd aan de containerinstallatiekopieën met behulp van Docker-labels, zoals opslagplaats, doorvoer, build- en release-informatie.
useDefaultContext
-
Standaardcontext voor build gebruiken
boolean
. Facultatief. Gebruiken wanneer command = Build an image || command = build
. Standaardwaarde: true
.
Hiermee geeft u het toevoegen of verwijderen van de buildcontext aan de map die het Docker-bestand bevat.
buildContext
-
context maken
string
. Facultatief. Gebruiken wanneer useDefaultContext = false
.
Hiermee geeft u het pad naar de buildcontext.
imageDigestFile
-
afbeeldingssamenvatingsbestand
string
. Facultatief. Gebruiken wanneer command = Push an image || command = push
.
Hiermee geeft u het pad naar een bestand dat is gemaakt en gevuld met de volledige samenvatting van de opslagplaats voor installatiekopieën van de Docker-installatiekopieën die is gepusht.
containerName
-
containernaam
string
. Facultatief. Gebruiken wanneer command = Run an image || command = run
.
Hiermee geeft u de naam op van de Docker-container die moet worden uitgevoerd.
ports
-
poorten
string
. Facultatief. Gebruiken wanneer command = Run an image || command = run
.
Hiermee geeft u de poorten in de Docker-container op die naar de host moeten worden gepubliceerd. Geef elke host-port:container-port
binding op een afzonderlijke regel weer.
volumes
-
volumes
string
. Facultatief. Gebruiken wanneer command = Run an image || command = run
.
Hiermee geeft u de volumes die van de host moeten worden gekoppeld. Geef elke host-dir:container-dir
op een afzonderlijke regel weer.
envVars
-
omgevingsvariabelen
string
. Facultatief. Gebruiken wanneer command = Run an image || command = run
.
Hiermee geeft u omgevingsvariabelen voor de Docker-container op. Geef elk name=value
paar op een afzonderlijke regel weer.
workingDirectory
-
werkmap
string
. Facultatief. Gebruiken wanneer command = Run an image || command = run
.
Hiermee geeft u de werkmap voor de Docker-container.
entrypointOverride
-
invoerpunt overschrijven
string
. Facultatief. Gebruiken wanneer command = Run an image || command = run
.
Hiermee geeft u op of het standaardinvoerpunt voor de Docker-container moet worden overschreven.
containerCommand
-
opdracht Container
string
. Facultatief. Gebruiken wanneer command = Run an image || command = run
.
Hiermee geeft u een Docker-run-opdracht. Met de docker-run-opdracht maakt u eerst een schrijfbare containerlaag over de opgegeven installatiekopieën en start u deze vervolgens met behulp van de opgegeven run-opdracht. Als de afbeelding bijvoorbeeld een eenvoudige Python Flask-webtoepassing bevat, kunt u python app.py
opgeven om de webtoepassing te starten.
runInBackground
-
uitvoeren op de achtergrond
boolean
. Facultatief. Gebruiken wanneer command = Run an image || command = run
. Standaardwaarde: true
.
Hiermee geeft u op of de Docker-container op de achtergrond moet worden uitgevoerd.
restartPolicy
-
beleid opnieuw opstarten
string
. Vereist wanneer runInBackground = true
. Toegestane waarden: no
, onFailure
(bij fout), always
, unlessStopped
(tenzij gestopt). Standaardwaarde: no
.
Hiermee geeft u op wanneer een beleid voor opnieuw opstarten moet worden uitgevoerd.
maxRestartRetries
-
nieuwe pogingen voor opnieuw opstarten
string
. Facultatief. Gebruiken wanneer runInBackground = true && restartPolicy = onFailure
.
Hiermee geeft u het maximum aantal nieuwe pogingen voor opnieuw opstarten van de Docker-daemonpogingen op.
dockerHostEndpoint
-
verbinding met de Docker-hostservice
string
. Facultatief. Gebruiken wanneer command != login && command != logout
.
Hiermee geeft u een Docker-hostserviceverbinding op. De standaardinstelling is de host van de agent.
enforceDockerNamingConvention
-
Naam van installatiekopieën geforceerd volgen
boolean
. Facultatief. Gebruiken wanneer command != login && command != logout
. Standaardwaarde: true
.
De standaardwaarde wijzigt de naam van de Docker-installatiekopieën volgens de naamconventies van Docker. Converteer bijvoorbeeld hoofdletters naar kleine letters en verwijder spaties.
memoryLimit
-
geheugenlimiet
string
. Facultatief. Gebruiken wanneer command != login && command != logout
.
Hiermee geeft u de maximale hoeveelheid geheugen die beschikbaar is voor de container als een geheel getal met optionele achtervoegsels, zoals 2GB
.
Opties voor taakbeheer
Alle taken hebben besturingsopties naast hun taakinvoer. Zie Opties en algemene taakeigenschappenvoor meer informatie.
Uitvoervariabelen
Deze taak definieert de volgende uitvoervariabelen, die u kunt gebruiken in downstreamstappen, taken en fasen.
DockerOutput
slaat de uitvoer van de docker-opdracht op
DockerOutputPath
het pad van het bestand dat de uitvoer van de build-opdracht bevat.
Deze taak definieert de volgende uitvoervariabelen, die u kunt gebruiken in downstreamstappen, taken en fasen.
DockerOutput
slaat de uitvoer van de docker-opdracht op
Opmerkingen
Docker@2 is een nieuwere versie van deze taak die de taak vereenvoudigt door invoer te verwijderen die als argumenten aan de opdracht kunnen worden doorgegeven.
Vereisten
Voorwaarde | Beschrijving |
---|---|
Pijplijntypen | YAML, klassieke build, klassieke release |
Wordt uitgevoerd op | Agent, DeploymentGroup |
eisen | Geen |
mogelijkheden | Deze taak voldoet niet aan de vereisten voor volgende taken in de taak. |
opdrachtbeperkingen | Welk dan ook |
variabelen instellen | Welk dan ook |
Agentversie | Alle ondersteunde agentversies. |
Taakcategorie | Bouwen |