Docker 이미지를 빌드, 태그 지정, 푸시 또는 실행하거나 Docker 명령을 실행합니다. Docker 또는 Azure Container Registry에서 이 작업을 사용합니다.
비고
Docker@2 명령에 인수로 전달할 수 있는 입력을 제거하여 작업을 간소화하는 이 작업의 최신 버전입니다.
구문론
# 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.
입력
컨테이너 레지스트리 유형containerregistrytype
-
string
;
command != logout
때 필요합니다. 허용되는 값: Azure Container Registry
, Container Registry
. 기본값은 Azure Container Registry
입니다.
Azure 서비스 연결을 사용하여 연결할 Azure Container Registry를 지정합니다. Azure Container Registry를 선택하여 Docker 허브 또는 다른 프라이빗 컨테이너 레지스트리에 연결합니다.
addBaseImageData
-
이미지에 기본 이미지 메타데이터 추가
boolean
; 기본값은 true
입니다.
기본값은 추적 기능을 돕기 위해 기본 이미지 이름 및 다이제스트와 같은 기본 이미지 데이터를 추가합니다. 이 값을 false
설정하여 이 기본 동작을 옵트아웃할 수 있습니다.
Docker 레지스트리 서비스 연결dockerRegistryEndpoint
-
string
; 선택 사항.
containerregistrytype = Container Registry && command != logout
때 사용합니다.
Docker 레지스트리 서비스 연결을 지정합니다. 레지스트리를 사용하여 인증하는 명령에 필요합니다.
Azure 구독
string
; 선택 사항.
containerregistrytype = Azure Container Registry && command != logout
때 사용합니다.
Azure 구독을 지정합니다.
Azure Container RegistryazureContainerRegistry
-
string
; 선택 사항.
containerregistrytype = Azure Container Registry && command != logout
때 사용합니다.
선택한 Azure 구독에서 Azure Container Registry를 지정합니다. 컨테이너 이미지가 빌드되고 이 컨테이너 레지스트리에 푸시됩니다.
command
-
명령
string
; 필수 사항입니다. 허용되는 값: Build an image
(빌드), Tag image
(태그), Push an image
(푸시), Run an image
(실행), login
, logout
. 기본값은 Build an image
입니다.
실행할 docker 명령을 지정합니다.
DockerfiledockerFile
-
string
;
command = Build an image || command = build
때 필요합니다. 기본값은 **/Dockerfile
입니다.
Docker 파일의 경로를 지정합니다. 작업은 이미지를 빌드하기 위해 찾은 첫 번째 Docker 파일을 사용합니다.
arguments
-
인수
string
; 선택 사항.
command != login && command != logout
때 사용합니다.
Docker 클라이언트에 전달할 추가 인수를 지정합니다. 명령 매개 변수에 buildAndPush
값을 사용하면 인수 속성이 무시됩니다.
여러 이미지 푸시pushMultipleImages
-
boolean
; 선택 사항.
command = Push an image || command = push
때 사용합니다. 기본값은 false
입니다.
푸시할 Docker 이미지의 텍스트 파일에 있는 목록을 지정합니다. 각 이미지 이름을 별도의 줄에 Imagename1:tag1
형식으로 나열합니다. 태그가 없는 이미지 이름(예: Imagename2
)을 나열하면 Imagename2
컨테이너의 모든 태그가 푸시됩니다.
tagMultipleImages
-
여러 이미지 태그 지정
boolean
; 선택 사항.
command = Tag image || command = tag
때 사용합니다. 기본값은 false
입니다.
텍스트 파일에서 태그를 지정할 여러 이미지 태그 및 Docker 이미지 목록을 지정합니다. 각 이미지 이름을 별도의 줄에 Imagename1:tag1
형식으로 나열합니다.
Imagename2
태그 없이 나열된 이미지는 기본적으로 최신 태그가 지정됩니다.
imageName
-
이미지 이름
string
;
command = Build an image || command = build || command = Run an image || command = run || pushMultipleImages = false || tagMultipleImages = false
때 필요합니다. 기본값은 $(Build.Repository.Name):$(Build.BuildId)
입니다.
빌드, 푸시 또는 실행할 Docker 이미지의 이름을 지정합니다.
imageNamesPath
-
이미지 이름 경로
string
;
tagMultipleImages = true || pushMultipleImages = true
때 필요합니다.
태그를 지정하거나 푸시할 Docker 이미지의 이름이 포함된 텍스트 파일의 경로를 지정합니다. 각 이미지 이름을 별도의 줄에 나열합니다.
이미지 이름한정 qualifyImageName
-
boolean
; 선택 사항.
command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push || command = Run an image || command = run
때 사용합니다. 기본값은 true
입니다.
Docker 레지스트리 서비스 연결의 호스트 이름을 사용하여 정규화된 이미지 이름을 지정합니다.
원본 이미지 이름한정 qualifySourceImageName
-
boolean
; 선택 사항.
command = Tag image || command = tag
때 사용합니다. 기본값은 false
입니다.
Docker 레지스트리 서비스 연결의 호스트 이름을 사용하여 정규화된 이미지 이름을 지정합니다.
includeSourceTags
-
원본 태그 포함
boolean
; 선택 사항.
command = Build an image || command = build || command = Tag image || command = tag || command = Push an image || command = push
때 사용합니다. 기본값은 false
입니다.
Docker 이미지를 빌드하거나 푸시할 때 포함할 Git 태그를 지정합니다.
includeLatestTag
-
최신 태그 포함
boolean
; 선택 사항.
command = Build an image || command = build
때 사용합니다. 기본값은 false
입니다.
Docker 이미지를 빌드할 때 최신 태그를 사용할지 여부를 지정합니다.
addDefaultLabels
-
기본 레이블 추가
boolean
; 선택 사항.
addDefaultLabels = false
때 사용합니다. 기본값은 true
입니다.
리포지토리, 커밋, 빌드 및 릴리스 정보와 같은 Docker 레이블을 사용하여 컨테이너 이미지에 CI/CD 메타데이터를 추가할지 여부를 지정합니다.
useDefaultContext
-
기본 빌드 컨텍스트 사용
boolean
; 선택 사항.
command = Build an image || command = build
때 사용합니다. 기본값은 true
입니다.
Docker 파일이 포함된 디렉터리에 빌드 컨텍스트를 추가하거나 제거하도록 지정합니다.
빌드 컨텍스트buildContext
-
string
; 선택 사항.
useDefaultContext = false
때 사용합니다.
빌드 컨텍스트의 경로를 지정합니다.
imageDigestFile
-
이미지 다이제스트 파일
string
; 선택 사항.
command = Push an image || command = push
때 사용합니다.
푸시된 Docker 이미지의 전체 이미지 리포지토리 다이제스트로 만들어지고 채워진 파일의 경로를 지정합니다.
containerName
-
컨테이너 이름
string
; 선택 사항.
command = Run an image || command = run
때 사용합니다.
실행할 Docker 컨테이너의 이름을 지정합니다.
ports
-
포트
string
; 선택 사항.
command = Run an image || command = run
때 사용합니다.
호스트에 게시할 Docker 컨테이너의 포트를 지정합니다. 각 host-port:container-port
바인딩을 별도의 줄에 나열합니다.
volumes
-
볼륨
string
; 선택 사항.
command = Run an image || command = run
때 사용합니다.
호스트에서 탑재할 볼륨을 지정합니다. 각 host-dir:container-dir
별도의 줄에 나열합니다.
envVars
-
환경 변수
string
; 선택 사항.
command = Run an image || command = run
때 사용합니다.
Docker 컨테이너에 대한 환경 변수를 지정합니다. 각 name=value
쌍을 별도의 줄에 나열합니다.
workingDirectory
-
작업 디렉터리
string
; 선택 사항.
command = Run an image || command = run
때 사용합니다.
Docker 컨테이너의 작업 디렉터리를 지정합니다.
entrypointOverride
-
진입점 재정의
string
; 선택 사항.
command = Run an image || command = run
때 사용합니다.
Docker 컨테이너의 기본 진입점을 재정의할지 여부를 지정합니다.
containerCommand
-
컨테이너 명령
string
; 선택 사항.
command = Run an image || command = run
때 사용합니다.
Docker 실행 명령을 지정합니다. docker run 명령은 먼저 지정된 이미지 위에 쓰기 가능한 컨테이너 계층을 만든 다음 지정된 실행 명령을 사용하여 시작합니다. 예를 들어 이미지에 간단한 Python Flask 웹 애플리케이션이 포함된 경우 웹 애플리케이션을 시작하는 python app.py
지정할 수 있습니다.
백그라운드runInBackground
- 실행
boolean
; 선택 사항.
command = Run an image || command = run
때 사용합니다. 기본값은 true
입니다.
백그라운드에서 Docker 컨테이너를 실행할지 여부를 지정합니다.
다시 시작 정책restartPolicy
-
string
;
runInBackground = true
때 필요합니다. 허용되는 값: no
, onFailure
(실패시), always
, unlessStopped
(중지되지 않는 한). 기본값은 no
입니다.
다시 시작 정책을 실행할 시기를 지정합니다.
maxRestartRetries
-
최대 다시 시작 다시 시도
string
; 선택 사항.
runInBackground = true && restartPolicy = onFailure
때 사용합니다.
Docker 디먼이 시도하는 최대 재시도 횟수를 지정합니다.
docker 호스트 서비스 연결dockerHostEndpoint
-
string
; 선택 사항.
command != login && command != logout
때 사용합니다.
Docker 호스트 서비스 연결을 지정합니다. 기본값은 에이전트의 호스트입니다.
enforceDockerNamingConvention
-
이미지 이름을 강제로 Docker 명명 규칙 따르도록 합니다.
boolean
; 선택 사항.
command != login && command != logout
때 사용합니다. 기본값은 true
입니다.
기본값은 Docker 명명 규칙에 따라 Docker 이미지 이름을 수정합니다. 예를 들어 대문자를 소문자로 변환하고 공백을 제거합니다.
memoryLimit
-
메모리 제한
string
; 선택 사항.
command != login && command != logout
때 사용합니다.
컨테이너에 사용할 수 있는 최대 메모리 양을 2GB
같은 선택적 접미사가 있는 정수로 지정합니다.
작업 제어 옵션
모든 작업에는 작업 입력 외에 제어 옵션이 있습니다. 자세한 내용은 컨트롤 옵션 및 일반적인 작업 속성참조하세요.
출력 변수
이 작업은 다운스트림 단계, 작업 및 단계에서 사용할 수 있는 다음 출력 변수정의합니다.
DockerOutput
docker 명령의 출력을 저장합니다.
DockerOutputPath
빌드 명령의 출력을 포함하는 파일의 경로입니다.
이 작업은 다운스트림 단계, 작업 및 단계에서 사용할 수 있는 다음 출력 변수정의합니다.
DockerOutput
docker 명령의 출력을 저장합니다.
비고
Docker@2 명령에 인수로 전달할 수 있는 입력을 제거하여 작업을 간소화하는 이 작업의 최신 버전입니다.
요구 사항
요구 사항 | 설명 |
---|---|
파이프라인 유형 | YAML, 클래식 빌드, 클래식 릴리스 |
다음에서 실행 | 에이전트, DeploymentGroup |
요구 | 없음 |
기능 | 이 작업은 작업의 후속 작업에 대한 요구 사항을 충족하지 않습니다. |
명령 제한 | 어느 것이든 |
settable 변수 | 어느 것이든 |
에이전트 버전 | 지원되는 모든 에이전트 버전입니다. |
작업 범주 | 빌드 |