Sdílet prostřednictvím


Docker@0 – úloha Dockeru v0

Sestavte, označte, nasdílejte, spusťte image Dockeru nebo spusťte příkaz Dockeru. Tuto úlohu použijte s Dockerem nebo službou Azure Container Registry.

Poznámka

Docker@2 je novější verze této úlohy, která zjednodušuje úlohu odebráním vstupů, které lze příkazu předat jako argumenty.

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.

Vstupy

containerregistrytype - Typ registru kontejneru
string. Povinná hodnota. Povolené hodnoty: Azure Container Registry, Container Registry. Výchozí hodnota: Azure Container Registry.

Vyberte Azure Container Registry a připojte se k němu pomocí připojení služby Azure. Vyberte Registr kontejneru a připojte se k Docker Hub nebo jinému privátnímu registru kontejneru.


dockerRegistryConnection - Připojení služby Registru Dockeru
Vstupní alias: dockerRegistryEndpoint. string. Nepovinný parametr. Použijte, když containerregistrytype = Container Registry.

Určuje připojení služby registru Dockeru. Vyžaduje se pro příkazy, které se potřebují ověřit pomocí registru.


azureSubscription - Předplatné Azure
Vstupní alias: azureSubscriptionEndpoint. string. Nepovinný parametr. Použijte, když containerregistrytype = Azure Container Registry.

Určuje předplatné Azure.


azureContainerRegistry - Azure Container Registry
string. Nepovinný parametr. Použijte, když containerregistrytype = Azure Container Registry.

Určuje Azure Container Registry ve vybraném předplatném Azure. Image kontejneru se sestaví a pak nasdílí do tohoto registru kontejneru.


action - Akce
string. Povinná hodnota. Povolené hodnoty: Build an image, Tag images, Push an imagePush images, , Run an image, . Run a Docker command Výchozí hodnota: Build an image.

Určuje akci Dockeru.


dockerFile - Soubor Dockeru
string. Vyžaduje se, když action = Build an image. Výchozí hodnota: **/Dockerfile.

Určuje cestu k souboru Dockeru. Úloha použije k sestavení image první soubor Dockeru, který najde.


addBaseImageData - Přidání metadat základního obrázku k obrázkům
boolean. Výchozí hodnota: true.

Výchozí hodnota přidá základní data obrázku, jako je název základní image a digest, a pomáhá tak sledovat. Odhlásit se můžete nastavením hodnoty na false.


buildArguments - Argumenty sestavení
string. Nepovinný parametr. Použijte, když action = Build an image.

Určuje proměnné v době sestavení pro soubor Dockeru. Naformátovat každý name=value pár na nový řádek.


defaultContext - Použít výchozí kontext sestavení
boolean. Nepovinný parametr. Použijte, když action = Build an image. Výchozí hodnota: true.

Určuje kontext sestavení adresáře, který obsahuje soubor Dockeru.


context - Kontext sestavení
string. Nepovinný parametr. Použijte, když action = Build an image && defaultContext = false.

Určuje cestu ke kontextu sestavení.


imageName - Název obrázku
string. Vyžaduje se, když action == Build an image || action == Push an image || action == Run an image. Výchozí hodnota: $(Build.Repository.Name):$(Build.BuildId).

Určuje název image Dockeru pro sestavení, vložení nebo spuštění.


imageNamesPath - Cesta k názvům obrázků
string. Vyžaduje se, když action == Tag images || action == Push images.

Určuje cestu k textovému souboru, který obsahuje názvy imagí Dockeru, které chcete označit nebo nasdílit. Vypište názvy jednotlivých obrázků na samostatný řádek.


qualifyImageName - Název obrázku kvalifikovat
boolean. Nepovinný parametr. Použijte, když action = Build an image || action = Tag images || action = Push an image || action = Push images || action = Run an image. Výchozí hodnota: true.

Určuje kvalifikovaný název image s názvem hostitele připojení služby registru Dockeru.


additionalImageTags - Další značky obrázků
string. Nepovinný parametr. Použijte, když action = Build an image || action = Tag images || action = Push an image || action = Push images.

Určuje další značky pro image Dockeru, která se sestavuje nebo nasdílí.


includeSourceTags - Zahrnout značky zdroje
boolean. Nepovinný parametr. Použijte, když action = Build an image || action = Tag image || action = Push an image || action = Push images. Výchozí hodnota: false.

Určuje, jestli se mají při sestavování nebo nabízení image Dockeru zahrnout značky Gitu.


includeLatestTag - Zahrnout nejnovější značku
boolean. Nepovinný parametr. Použijte, když action = Build an image || action = Push an image || action = Push images. Výchozí hodnota: false.

Určuje, jestli se má při sestavování nebo nabízení image Dockeru zahrnout nejnovější značka.


imageDigestFile - Soubor digest obrázku
string. Nepovinný parametr. Použijte, když action = Push an image || action = Push images.

Určuje cestu k souboru, který se vytvoří a naplní hodnotou digest úložiště úplného úložiště imagí z image Dockeru, která byla nasdílena.


containerName - Název kontejneru
string. Nepovinný parametr. Použijte, když action = Run an image.

Určuje název kontejneru Dockeru, který se má spustit.


ports - Porty
string. Nepovinný parametr. Použijte, když action = Run an image.

Určuje porty v kontejneru Dockeru, které se mají publikovat na hostiteli. Vypíše každou host-port:container-port vazbu na nový řádek.


volumes - Svazky
string. Nepovinný parametr. Použijte, když action = Run an image.

Určuje svazky, které se mají připojit z hostitele. Vypsat každou host-dir:container-dir položku na nový řádek.


envVars - Proměnné prostředí
string. Nepovinný parametr. Použijte, když action = Run an image.

Určuje proměnné prostředí pro kontejner Dockeru. Vypíše každou name=value dvojici na nový řádek.


workDir - Pracovní adresář
string. Nepovinný parametr. Použijte, když action = Run an image.

Určuje pracovní adresář pro kontejner Dockeru.


entrypoint - Přepsání vstupního bodu
string. Nepovinný parametr. Použijte, když action = Run an image.

Určuje přepsání výchozího vstupního bodu pro kontejner Dockeru.


containerCommand - Příkaz
string. Nepovinný parametr. Použijte, když action = Run an image.

Určuje příkaz Docker run. Příkaz docker run nejprve vytvoří zapisovatelnou vrstvu kontejneru nad zadanou image a pak ji spustí pomocí zadaného příkazu run. Pokud například obrázek obsahuje jednoduchou webovou aplikaci Python Flask, můžete určit python app.py spuštění webové aplikace.


detached - Spustit na pozadí
boolean. Nepovinný parametr. Použijte, když action = Run an image. Výchozí hodnota: true.

Určuje, jestli se má kontejner Dockeru spustit na pozadí.


restartPolicy - Zásady restartování
string. Vyžaduje se, když action = Run an image && detached = true. Povolené hodnoty: no, onFailure (Při selhání), always, unlessStopped (Pokud není zastaveno). Výchozí hodnota: no.

Určuje zásadu restartování.


restartMaxRetries - Maximální počet opakování restartování
string. Nepovinný parametr. Použijte, když action = Run an image && detached = true && restartPolicy = onFailure.

Určuje maximální počet opakovaných pokusů o restartování, které se démon Dockeru pokusí.


customCommand - Příkaz
string. Vyžaduje se, když action = Run a Docker command.

Určuje příkaz Dockeru a argumenty, které se mají provést. rmi -f image-name Například odebere obrázek.


dockerHostEndpoint - Připojení hostitelské služby Dockeru
string.

Určuje připojení služby hostitele Dockeru. Výchozí hodnota je hostitel agenta.


enforceDockerNamingConvention - Vynutit, aby název image dodržoval zásady vytváření názvů v Dockeru
boolean. Výchozí hodnota: true.

Pokud je povoleno, upraví název image Dockeru podle konvencí vytváření názvů Dockeru. Můžete například převést velká písmena na malá písmena a odebrat mezery.


workingDirectory - Pracovní adresář
Alias vstupu: cwd. string. Výchozí hodnota: $(System.DefaultWorkingDirectory).

Určuje pracovní adresář pro příkaz Dockeru.


memory - Limit paměti
string.

Určuje maximální velikost paměti dostupnou pro kontejner jako celé číslo s volitelnými příponami, například 2GB.


Možnosti ovládání úloh

Všechny úlohy mají kromě vstupů také možnosti ovládání. Další informace najdete v tématu Možnosti ovládacích prvků a běžné vlastnosti úlohy.

Výstupní proměnné

Tato úloha definuje následující výstupní proměnné, které můžete využívat v podřízených krocích, úlohách a fázích.

DockerOutput
Uloží výstup příkazu dockeru.

DockerOutputPath
Cesta k souboru, který obsahuje výstup příkazu sestavení.

Tato úloha definuje následující výstupní proměnné, které můžete využívat v podřízených krocích, úlohách a fázích.

DockerOutput
Uloží výstup příkazu dockeru.

Poznámky

Docker@2 je novější verze této úlohy, která zjednodušuje úlohu odebráním vstupů, které lze příkazu předat jako argumenty.

Požadavky

Požadavek Popis
Typy kanálů YAML, klasický build, klasická verze
Běží na Agent, DeploymentGroup
Požadavky Žádné
Možnosti Tento úkol nesplňuje žádné požadavky na následné úkoly v úloze.
Omezení příkazů Všechny
Nastavitelné proměnné Všechny
Verze agenta Všechny podporované verze agenta.
Kategorie úloh Sestavení

Viz také