Get started with Bitbucket Cloud
New to Bitbucket Cloud? Check out our get started guides for new users.
Bitbucket Pipelines runs most builds in Docker containers (excluding builds on the Linux shell, macOS, and Windows runners). The image options allow you to use custom Docker images as build environments. Most of these options relate to pulling images from private Docker registries.
We support public and private Docker images including those hosted on Docker Hub, AWS, GCP, Azure, and self-hosted registries accessible on the internet. Bitbucket Pipelines can't currently access Docker images that can't be accessed through the internet.
For details on using custom Docker images with Bitbucket Pipelines, see Use Docker images as build environments.
The following options can be used to set the Docker image for pipeline steps globally within a bitbucket-pipelines.yml, for individual steps, or for service containers:
Bitbucket Pipelines uses Docker containers when it runs your builds either:
On Bitbucket Cloud’s infrastructure, or
On a Linux Docker self-hosted runner.
You can use the default image (atlassian/default-image:latest) provided by Bitbucket or define a custom image. You can specify any public or private Docker image that isn't hosted on a private network. The image used can be set at the global level, and overridden for individual steps.
The image option can be used to specify public images or private images. For publicly-accessible Docker images, you can use image as a single-line option such as:
1
image: atlassian/default-image:latest
For private images, use the block version of the image option, such as:
1
2
3
4
image:
name: us-east1-docker.pkg.dev/my-project/my-repo/test-image:latest
username: $DOCKER_REGISTRY_USERNAME
password: $DOCKER_REGISTRY_PASSWORD
For information about using and creating images, see Use Docker images as build environments.
Property — image
Required — No
Data type — Either:
string
block of new-line separated key-value pairs (YAML spec - Block Mapping)
Default value — atlassian/default-image:latest (For details, see Use Docker images as build environments — Default build environment)
Allowed parent properties — services, step, or the YAML root (image can be a top-level property)
Allowed child properties — name, username, password, aws, and run-as-user
1
2
3
4
5
6
7
8
image: bash:latest # https://hub.docker.com/_/bash
pipelines:
default:
- step:
name: Hello world example
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
13
image: bash:latest # https://hub.docker.com/_/bash
pipelines:
default:
- step:
name: Step using the Bash image
script:
- bash --version
- step:
name: Step using the default Bitbucket Pipelines image
image: atlassian/default-image:latest # https://hub.docker.com/r/atlassian/default-image/
script:
- echo "Hello, World from the default Pipelines image"
1
2
3
4
5
6
7
8
9
10
11
12
13
image: public.ecr.aws/docker/library/python:slim # https://gallery.ecr.aws/docker/library/python
pipelines:
default:
- step:
name: Step using the Python image
script:
- echo "Python version:" $(python --version)
- step:
name: Step using the default Bitbucket Pipelines image
image: atlassian/default-image:latest # https://hub.docker.com/r/atlassian/default-image/
script:
- echo "Node.js version:" $(node -v)
This example shows how to pull a private image from Docker Hub (actual use may vary depending on your Docker Hub authentication method).
1
2
3
4
5
6
7
8
9
10
11
12
image:
name: my-docker-hub-account/my-docker-image:latest
username: $DOCKER_HUB_USERNAME
password: $DOCKER_HUB_PASSWORD
run-as-user: 1001
pipelines:
default:
- step:
name: Hello world example
script:
- echo "Hello, World!"
This example shows how to pull a private image from a non-Docker Hub image repository (in this case, Google Artifact Registry).
1
2
3
4
5
6
7
8
9
10
11
image:
name: us-east1-docker.pkg.dev/my-project/my-repo/test-image:latest
username: $DOCKER_REGISTRY_USERNAME
password: $DOCKER_REGISTRY_PASSWORD
pipelines:
default:
- step:
name: Hello world example
script:
- echo "Hello, World!"
The image name property is used to specify which Docker image to use when you are using a private image and login credentials are required. For details on configuring access to private Docker images, see Use Docker images as build environments — Using private build images.
Property — name
Required — No
Data type — String
Allowed parent properties — image
1
2
3
4
5
6
7
8
image:
name: my-account/bash:latest
pipelines:
default:
- step:
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
image: my/bash:lts
pipelines:
default:
- step:
image:
name: my/bash:latest
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
13
definitions:
services:
my-service:
image:
name: my/bash:latest
pipelines:
default:
- step:
services:
- my-service
script:
- echo "Hello, World!"
The image username property, when used with the password property, provides Bitbucket Pipelines with access to private Docker images. For details on configuring access to private Docker images, see Use Docker images as build environments — Using private build images.
Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.
Property — username
Required — No
Data type — String
Allowed parent properties — image
1
2
3
4
5
6
7
8
9
10
image:
name: my/bash:latest
username: $CONTAINER_REGISTRY_USERNAME
password: $CONTAINER_REGISTRY_PASSWORD
pipelines:
default:
- step:
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
image: my/bash:lts
pipelines:
default:
- step:
image:
name: my/bash:latest
username: $CONTAINER_REGISTRY_USERNAME
password: $CONTAINER_REGISTRY_PASSWORD
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
definitions:
services:
my-service:
image:
name: my/bash:latest
username: $CONTAINER_REGISTRY_USERNAME
password: $CONTAINER_REGISTRY_PASSWORD
pipelines:
default:
- step:
services:
- my-service
script:
- echo "Hello, World!"
The image password property, when used with the username property, provides Bitbucket Pipelines with access to private Docker images. For details on configuring access to private Docker images, see Use Docker images as build environments — Using private build images.
Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.
Property — password
Required — No
Data type — String
Allowed parent properties — image
1
2
3
4
5
6
7
8
9
10
image:
name: my/bash:latest
username: $CONTAINER_REGISTRY_USERNAME
password: $CONTAINER_REGISTRY_PASSWORD
pipelines:
default:
- step:
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
image: my/bash:lts
pipelines:
default:
- step:
image:
name: my/bash:latest
username: $CONTAINER_REGISTRY_USERNAME
password: $CONTAINER_REGISTRY_PASSWORD
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
definitions:
services:
my-service:
image:
name: my/bash:latest
username: $CONTAINER_REGISTRY_USERNAME
password: $CONTAINER_REGISTRY_PASSWORD
pipelines:
default:
- step:
services:
- my-service
script:
- echo "Hello, World!"
An image's default user can be overridden by specifying a user UID with the run-as-user property. The specified user UID needs to be a user already defined in the image and should have a valid home directory.
Property — run-as-user
Required — No
Data type — Integer
Allowed values — UID of any user on the image
Default value — 0 (root user)
Allowed parent properties — image
1
2
3
4
5
6
7
8
9
image:
name: my/bash:latest
run-as-user: 1000
pipelines:
default:
- step:
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
image: my/bash:lts
pipelines:
default:
- step:
image:
name: my/bash:lts
run-as-user: 1000
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
definitions:
services:
my-service:
image:
name: my/bash:latest
run-as-user: 1000
pipelines:
default:
- step:
services:
- my-service
script:
- echo "Hello, World!"
The image aws properties allow pipelines to use private images hosted in an Amazon Elastic Container Registry (AWS ECR). The aws property supports two authentication methods:
using an access key and a secret key (access-key and secret-key)
using an OpenID Connect (OIDC) role (oidc-role).
For details, see Private images hosted by AWS ECR (EC2 Container Registry).
Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.
Property — aws
Required — No
Data type — Block of new-line separated key-value pairs (YAML spec - Block Mapping)
Allowed parent properties — image
Allowed child properties — Requires either:
1
2
3
4
5
6
7
8
9
10
11
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
access-key: $AWS_ACCESS_KEY
secret-key: $AWS_SECRET_KEY
pipelines:
default:
- step:
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
oidc-role: arn:aws:iam::<aws_account_id>:role/<your_role_name>
pipelines:
default:
- step:
script:
- echo "Hello, World!"
When using private images from an Amazon Elastic Container Registry (AWS ECR), you will need to use the access-key and secret-key options.
The aws access-key property, when used with the secret-key property, provides Bitbucket Pipelines with access to private Docker images hosted in an Amazon Elastic Container Registry (AWS ECR). For details, see Private images hosted by AWS ECR (EC2 Container Registry).
Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.
Property — access-key
Required — No
Data type — String
Allowed parent properties — aws
1
2
3
4
5
6
7
8
9
10
11
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
access-key: $AWS_ACCESS_KEY
secret-key: $AWS_SECRET_KEY
pipelines:
default:
- step:
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
image: my/bash:lts
pipelines:
default:
- step:
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
access-key: $AWS_ACCESS_KEY
secret-key: $AWS_SECRET_KEY
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
definitions:
services:
my-service:
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
access-key: $AWS_ACCESS_KEY
secret-key: $AWS_SECRET_KEY
pipelines:
default:
- step:
services:
- my-service
script:
- echo "Hello, World!"
The aws secret-key property, when used with the access-key property, provides Bitbucket Pipelines with access to private Docker images hosted in an Amazon Elastic Container Registry (AWS ECR). For details, see Private images hosted by AWS ECR (EC2 Container Registry).
Secrets and login credentials should be stored as user-defined pipeline variables to avoid being leaked. For details, see Variables and secrets — User-defined variables.
Property — secret-key
Required — No
Data type — String
Allowed parent properties — aws
1
2
3
4
5
6
7
8
9
10
11
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
access-key: $AWS_ACCESS_KEY
secret-key: $AWS_SECRET_KEY
pipelines:
default:
- step:
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
image: my/bash:lts
pipelines:
default:
- step:
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
access-key: $AWS_ACCESS_KEY
secret-key: $AWS_SECRET_KEY
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
definitions:
services:
my-service:
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
access-key: $AWS_ACCESS_KEY
secret-key: $AWS_SECRET_KEY
pipelines:
default:
- step:
services:
- my-service
script:
- echo "Hello, World!"
The aws oidc-role property provides Bitbucket Pipelines with access to private Docker images hosted in an Amazon Elastic Container Registry (AWS ECR). For details, see Use AWS ECR images in Pipelines with OpenID Connect.
Property — oidc-role
Required — No
Data type — String
Allowed parent properties — aws
1
2
3
4
5
6
7
8
9
10
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
oidc-role: arn:aws:iam::<aws_account_id>:role/<your_role_name>
pipelines:
default:
- step:
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
image: my/bash:lts
pipelines:
default:
- step:
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
oidc-role: arn:aws:iam::<aws_account_id>:role/<your_role_name>
script:
- echo "Hello, World!"
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
definitions:
services:
my-service:
image:
name: <aws_account_id>.dkr.ecr.<region>.amazonaws.com/bash:latest
aws:
oidc-role: arn:aws:iam::<aws_account_id>:role/<your_role_name>
pipelines:
default:
- step:
services:
- my-service
script:
- echo "Hello, World!"
Was this helpful?