jobs.job.container definition

Container jobs allow you to run jobs on a container instead of the agent host.

Properties that use this definition: pipeline.container, jobs.job.container

Properties that use this definition: pipeline.container, jobs.job.container, jobs.deployment.container

Properties that use this definition: pipeline.container, jobs.job.container, jobs.deployment.container

Properties that use this definition: pipeline.container, jobs.job.container, jobs.deployment.container

Properties that use this definition: pipeline.container, jobs.job.container, jobs.deployment.container

Overloads

Overload Description
container: string Specify job container by alias.
container: image Specify job container using image tag and options.
Overload Description
container: string Specify job container by alias.
container: image Specify job container using image tag and options.
Overload Description
container: string Specify job container by alias.
container: image Specify job container using image tag and options.
Overload Description
container: string Specify job container by alias.
container: image Specify job container using image tag and options.
Overload Description
container: string Specify job container by alias.
container: image Specify job container using image tag and options.

container: string

Specify job container using an alias.

container: string # 

Properties

jobContainer

string


container: string # 

Properties

jobContainer

string


container: string # 

Properties

jobContainer

string


container: string # 

Properties

jobContainer

string


container: string # 

Properties

jobContainer

string


Remarks

The alias can be the name of an image, or it can be a reference to a container resource.

Examples

The following example fetches the ubuntu image tagged 18.04 from Docker Hub and then starts the container. When the printenv command runs, it happens inside the ubuntu:18.04 container.

pool:
  vmImage: 'ubuntu-18.04'

container: ubuntu:18.04

steps:
- script: printenv

container: image

Specify job container using image tag and options.

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. 

Properties

endpoint

string

ID of the service endpoint connecting to a private container registry.

env

string name/value pairs

Variables to map into the container's environment.

image

string

Required. Container image tag.

options

string

Options to pass into container host.

ports

string list

Ports to expose on the container.

volumes

string list

Volumes to mount on the container.

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.  (false,n,no,off,on,true,y,yes)
  options: string # Options to pass into container host. 
  ports: [ string ] # Ports to expose on the container. 
  volumes: [ string ] # Volumes to mount on the container. 

Properties

endpoint

string

ID of the service endpoint connecting to a private container registry.

env

string name/value pairs

Variables to map into the container's environment.

image

string

Required. Container image tag.

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 list

Ports to expose on the container.

volumes

string list

Volumes to mount on the container.

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.  (false,n,no,off,on,true,y,yes)
  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.  (false,n,no,off,on,true,y,yes)
    externals: boolean # Mount the externals directory as readonly.  (false,n,no,off,on,true,y,yes)
    tools: boolean # Mount the tools directory as readonly.  (false,n,no,off,on,true,y,yes)
    tasks: boolean # Mount the tasks directory as readonly.  (false,n,no,off,on,true,y,yes)

Properties

endpoint

string

ID of the service endpoint connecting to a private container registry.

env

string name/value pairs

Variables to map into the container's environment.

image

string

Required. Container image tag.

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 list

Ports to expose on the container.

volumes

string list

Volumes to mount on the container.

mountReadOnly

string/boolean pairs

Volumes to mount read-only, the default is all false.

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.  (false,n,no,off,on,true,y,yes)
  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.  (false,n,no,off,on,true,y,yes)
    externals: boolean # Mount the externals directory as readonly.  (false,n,no,off,on,true,y,yes)
    tools: boolean # Mount the tools directory as readonly.  (false,n,no,off,on,true,y,yes)
    tasks: boolean # Mount the tasks directory as readonly.  (false,n,no,off,on,true,y,yes)

Properties

endpoint

string

ID of the service endpoint connecting to a private container registry.

env

string name/value pairs

Variables to map into the container's environment.

image

string

Required. Container image tag.

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 list

Ports to expose on the container.

volumes

string list

Volumes to mount on the container.

mountReadOnly

string/boolean pairs

Volumes to mount read-only, the default is all false.

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.  (false,n,no,off,on,true,y,yes)
  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.  (false,n,no,off,on,true,y,yes)
    externals: boolean # Mount the externals directory as readonly.  (false,n,no,off,on,true,y,yes)
    tools: boolean # Mount the tools directory as readonly.  (false,n,no,off,on,true,y,yes)
    tasks: boolean # Mount the tasks directory as readonly.  (false,n,no,off,on,true,y,yes)

Properties

endpoint

string

ID of the service endpoint connecting to a private container registry.

env

string name/value pairs

Variables to map into the container's environment.

image

string

Required. Container image tag.

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 list

Ports to expose on the container.

volumes

string list

Volumes to mount on the container.

mountReadOnly

string/boolean pairs

Volumes to mount read-only, the default is all false.

Examples

Use options to configure container startup.

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

steps:
- script: echo hello

In the following example, the containers are defined in the resources section. Each container is then referenced later, by referring to its assigned alias.

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

See also