title | description | ms.date | monikerRange |
---|---|---|---|
jobs.job.container definition |
Container resource name. |
03/02/2023 |
>=azure-pipelines-2019.1 |
:::moniker range=">=azure-pipelines-2019.1"
Container jobs allow you to run jobs on a container instead of the agent host.
:::moniker-end
:::moniker range=">=azure-pipelines-2020"
Definitions that that reference this definition: pipeline, jobs.job, jobs.deployment
:::moniker-end
:::moniker range="=azure-pipelines-2019.1"
Definitions that that reference this definition: pipeline, jobs.job
:::moniker-end
:::moniker range=">=azure-pipelines-2019.1"
Implementation | Description |
---|---|
container: string | Specify job container by alias. |
container: image | Specify job container using image tag and options. |
:::moniker-end
:::moniker range=">=azure-pipelines-2019.1"
Specify job container by alias.
container: string # Specify job container by alias.
container
string.
Specify job container by alias.
:::moniker-end
The alias can be the name of an image, or it can be a reference to a container resource.
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
:::moniker range=">=azure-pipelines-2020.1"
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
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
string. Required.
Container image tag.
endpoint
string.
ID of the service endpoint connecting to a private container registry.
env
string dictionary.
Variables to map into the container's environment.
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
mountReadOnly.
Volumes to mount read-only, the default is all false.
:::moniker-end
:::moniker range="=azure-pipelines-2020"
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
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
string. Required.
Container image tag.
endpoint
string.
ID of the service endpoint connecting to a private container registry.
env
string dictionary.
Variables to map into the container's environment.
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.
:::moniker-end
:::moniker range="=azure-pipelines-2019.1"
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.
image
string. Required.
Container image tag.
endpoint
string.
ID of the service endpoint connecting to a private container registry.
env
string dictionary.
Variables to map into the container's environment.
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.
:::moniker-end
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