title | description | ms.date | monikerRange |
---|---|---|---|
resources.containers.container definition |
A container resource used to reference a container image. |
11/20/2024 |
<=azure-pipelines |
:::moniker range="<=azure-pipelines"
A container resource references a container image.
:::moniker-end
:::moniker range=">=azure-pipelines-2020.1"
containers:
- container: string # Required as first property. Alias of the container.
image: string # Required. Container image tag.
type: string # Type of the registry like ACR or GCR.
trigger: trigger | none | true # Specify none to disable, true to trigger on all image tags, or use the full syntax as described in the following examples.
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.
azureSubscription: string # Azure subscription (ARM service connection) for container registry.
resourceGroup: string # Resource group for your ACR.
registry: string # Registry for container images.
repository: string # Name of the container image repository in ACR.
localImage: boolean # When true, uses a locally tagged image instead of using docker pull to get the image. The default is false.
:::moniker-end
:::moniker range="=azure-pipelines-2020"
containers:
- container: string # Required as first property. Alias of the container.
type: string # Type of the registry like ACR or GCR.
endpoint: string # ID of the service endpoint connecting to a private container registry.
trigger: trigger | none | true # Specify none to disable, true to trigger on all image tags, or use the full syntax as described in the following examples.
azureSubscription: string # Azure subscription (ARM service connection) for container registry.
resourceGroup: string # Resource group for your ACR.
registry: string # Registry for container images.
repository: string # Name of the container image repository in ACR.
localImage: boolean # When true, uses a locally tagged image instead of using docker pull to get the image. The default is false.
:::moniker-end
:::moniker range="<=azure-pipelines-2019.1"
containers:
- container: string # Required as first property. Alias of the container.
endpoint: string # ID of the service endpoint connecting to a private container registry.
azureSubscription: string # Azure subscription (ARM service connection) for container registry.
resourceGroup: string # Resource group for your ACR.
registry: string # Registry for container images.
repository: string # Name of the container image repository in ACR.
localImage: boolean # When true, uses a locally tagged image instead of using docker pull to get the image. The default is false.
:::moniker-end
:::moniker range="<=azure-pipelines"
Definitions that reference this definition: resources.containers
:::moniker-end
:::moniker range="<=azure-pipelines"
container
string. Required as first property.
ID for the container. Acceptable values: [-_A-Za-z0-9]*.
:::moniker-end
:::moniker range=">=azure-pipelines-2020.1"
image
string. Required.
Container image tag.
:::moniker-end
:::moniker range=">=azure-pipelines-2020"
type
string.
Type of the registry like ACR or GCR.
:::moniker-end
:::moniker range=">=azure-pipelines-2020"
trigger
resources.containers.container.trigger.
Specify none to disable, true to trigger on all image tags, or use the full syntax as described in the following examples.
:::moniker-end
:::moniker range=">=azure-pipelines-2022.1"
endpoint
string.
ID of the service endpoint connecting to a private container registry. Template expressions are supported.
:::moniker-end
:::moniker range="<=azure-pipelines-2022"
endpoint
string.
ID of the service endpoint connecting to a private container registry.
:::moniker-end
:::moniker range=">=azure-pipelines-2020.1"
env
string dictionary.
Variables to map into the container's environment.
:::moniker-end
:::moniker range=">=azure-pipelines-2020.1"
mapDockerSocket
boolean.
Set this flag to false to force the agent not to setup the /var/run/docker.sock volume on container jobs.
:::moniker-end
:::moniker range=">=azure-pipelines-2022.1"
options
string.
Options to pass into container host. Template expressions are supported.
:::moniker-end
:::moniker range=">=azure-pipelines-2020.1 <=azure-pipelines-2022"
options
string.
Options to pass into container host.
:::moniker-end
:::moniker range=">=azure-pipelines-2022.1"
ports
string list.
Ports to expose on the container. Template expressions are supported.
:::moniker-end
:::moniker range=">=azure-pipelines-2020.1 <=azure-pipelines-2022"
ports
string list.
Ports to expose on the container.
:::moniker-end
:::moniker range=">=azure-pipelines-2022.1"
volumes
string list.
Volumes to mount on the container. Template expressions are supported.
:::moniker-end
:::moniker range=">=azure-pipelines-2020.1 <=azure-pipelines-2022"
volumes
string list.
Volumes to mount on the container.
:::moniker-end
:::moniker range=">=azure-pipelines-2020.1"
mountReadOnly
mountReadOnly.
Volumes to mount read-only, the default is all false.
:::moniker-end
:::moniker range="<=azure-pipelines"
azureSubscription
string.
Azure subscription (ARM service connection) for container registry.
:::moniker-end
:::moniker range="<=azure-pipelines"
resourceGroup
string.
Resource group for your ACR.
:::moniker-end
:::moniker range="<=azure-pipelines"
registry
string.
Registry for container images.
:::moniker-end
:::moniker range="<=azure-pipelines"
repository
string.
Name of the container image repository in ACR.
:::moniker-end
:::moniker range="<=azure-pipelines"
localImage
boolean.
When true, uses a locally tagged image instead of using docker pull to get the image. The default is false.
This property is useful only for self-hosted agents where the image is already present on the agent machine.
:::moniker-end
Container jobs let you isolate your tools and dependencies inside a container.
The agent launches an instance of your specified container then runs steps inside it.
The container
keyword lets you specify your container images.
Service containers run alongside a job to provide various dependencies like databases.
::: moniker range=">=azure-pipelines-2022.1"
Template expressions are supported for endpoint
, volumes
, ports
, and options
properties of a container resource in a YAML pipeline.
::: moniker-end
resources:
containers:
- container: linux
image: ubuntu:16.04
- container: windows
image: myprivate.azurecr.io/windowsservercore:1803
endpoint: my_acr_connection
- container: my_service
image: my_service:tag
ports:
- 8080:80 # bind container port 80 to 8080 on the host machine
- 6379 # bind container port 6379 to a random available port on the host machine
volumes:
- /src/dir:/dst/dir # mount /src/dir on the host into /dst/dir in the container