Share via


jobs.job.container 정의

컨테이너 작업을 사용하면 에이전트 호스트 대신 컨테이너에서 작업을 실행할 수 있습니다.

이 정의를 참조하는 정의: pipeline, jobs.job, jobs.deployment

이 정의를 참조하는 정의: pipeline, jobs.job

구현

구현 설명
container: string 별칭으로 작업 컨테이너를 지정합니다.
container: image 이미지 태그 및 옵션을 사용하여 작업 컨테이너를 지정합니다.

container: string

별칭으로 작업 컨테이너를 지정합니다.

container: string # Specify job container by alias.

container 문자열.

별칭으로 작업 컨테이너를 지정합니다.

설명

별칭은 이미지의 이름이거나 컨테이너 리소스에 대한 참조일 수 있습니다.

예제

다음 예제에서는 Docker Hub 18.04 태그가 지정된 ubuntu 이미지를 가져온 다음 컨테이너를 시작합니다. 명령이 printenv 실행되면 ubuntu:18.04 컨테이너 내에서 발생합니다.

pool:
  vmImage: 'ubuntu-18.04'

container: ubuntu:18.04

steps:
- script: printenv

container: image

이미지 태그 및 옵션을 사용하여 작업 컨테이너를 지정합니다.

container:
  image: string # Required. Container image tag.
  endpoint: string # ID of the service endpoint connecting to a private container registry.
  env: # Variables to map into the container's environment.
    string: string # Name/value pairs
  mapDockerSocket: boolean # Set this flag to false to force the agent not to setup the /var/run/docker.sock volume on container jobs.
  options: string # Options to pass into container host.
  ports: [ string ] # Ports to expose on the container.
  volumes: [ string ] # Volumes to mount on the container.
  mountReadOnly: # Volumes to mount read-only, the default is all false.
    work: boolean # Mount the work directory as readonly.
    externals: boolean # Mount the externals directory as readonly.
    tools: boolean # Mount the tools directory as readonly.
    tasks: boolean # Mount the tasks directory as readonly.

속성

image 문자열. 필수 사항입니다.
컨테이너 이미지 태그입니다.

endpoint 문자열.
프라이빗 컨테이너 레지스트리에 연결하는 서비스 엔드포인트의 ID입니다.

env 문자열 사전입니다.
컨테이너의 환경에 매핑할 변수입니다.

mapDockerSocketboolean입니다.
에이전트가 컨테이너 작업에서 /var/run/docker.sock 볼륨을 설정하지 않도록 하려면 이 플래그를 false로 설정합니다.

options 문자열.
컨테이너 호스트에 전달할 옵션입니다.

ports 문자열 목록입니다.
컨테이너에 노출할 포트입니다.

volumes 문자열 목록입니다.
컨테이너에 탑재할 볼륨입니다.

mountReadOnlymountReadOnly.
읽기 전용으로 탑재할 볼륨의 기본값은 모두 false입니다.

container: image

이미지 태그 및 옵션을 사용하여 작업 컨테이너를 지정합니다.

container:
  image: string # Required. Container image tag.
  endpoint: string # ID of the service endpoint connecting to a private container registry.
  env: # Variables to map into the container's environment.
    string: string # Name/value pairs
  mapDockerSocket: boolean # Set this flag to false to force the agent not to setup the /var/run/docker.sock volume on container jobs.
  options: string # Options to pass into container host.
  ports: [ string ] # Ports to expose on the container.
  volumes: [ string ] # Volumes to mount on the container.

속성

image 문자열. 필수 사항입니다.
컨테이너 이미지 태그입니다.

endpoint 문자열.
프라이빗 컨테이너 레지스트리에 연결하는 서비스 엔드포인트의 ID입니다.

env 문자열 사전입니다.
컨테이너의 환경에 매핑할 변수입니다.

mapDockerSocketboolean입니다.
에이전트가 컨테이너 작업에서 /var/run/docker.sock 볼륨을 설정하지 않도록 하려면 이 플래그를 false로 설정합니다.

options 문자열.
컨테이너 호스트에 전달할 옵션입니다.

ports 문자열 목록입니다.
컨테이너에 노출할 포트입니다.

volumes 문자열 목록입니다.
컨테이너에 탑재할 볼륨입니다.

container: image

이미지 태그 및 옵션을 사용하여 작업 컨테이너를 지정합니다.

container:
  image: string # Required. Container image tag.
  endpoint: string # ID of the service endpoint connecting to a private container registry.
  env: # Variables to map into the container's environment.
    string: string # Name/value pairs
  options: string # Options to pass into container host.
  ports: [ string ] # Ports to expose on the container.
  volumes: [ string ] # Volumes to mount on the container.

속성

image 문자열. 필수 사항입니다.
컨테이너 이미지 태그입니다.

endpoint 문자열.
프라이빗 컨테이너 레지스트리에 연결하는 서비스 엔드포인트의 ID입니다.

env 문자열 사전입니다.
컨테이너의 환경에 매핑할 변수입니다.

options 문자열.
컨테이너 호스트에 전달할 옵션입니다.

ports 문자열 목록입니다.
컨테이너에 노출할 포트입니다.

volumes 문자열 목록입니다.
컨테이너에 탑재할 볼륨입니다.

예제

를 사용하여 options 컨테이너 시작을 구성합니다.

container:
  image: ubuntu:18.04
  options: --hostname container-test --ip 192.168.0.1

steps:
- script: echo hello

다음 예제에서 컨테이너는 리소스 섹션에서 정의됩니다. 그런 다음 각 컨테이너는 할당된 별칭을 참조하여 나중에 참조됩니다.

resources:
  containers:
  - container: u14
    image: ubuntu:14.04

  - container: u16
    image: ubuntu:16.04

  - container: u18
    image: ubuntu:18.04

jobs:
- job: RunInContainer
  pool:
    vmImage: 'ubuntu-18.04'

  strategy:
    matrix:
      ubuntu14:
        containerResource: u14
      ubuntu16:
        containerResource: u16
      ubuntu18:
        containerResource: u18

  container: $[ variables['containerResource'] ]

  steps:
  - script: printenv

추가 정보