Use your Docker images in self-hosted runners
When you use a self-hosted runner, you may want to pull the Atlassian public Docker images from your own registry or use modified versions of our public Docker images.
To use Docker images from a custom Docker registry in your self-hosted runner, you can configure them using:PAUSE_IMAGE,AUTH_PROXY_IMAGE, andCLONE_IMAGE.
Example
docker container run -it -v /tmp:/tmp \-v /var/run/docker.sock:/var/run/docker.sock \-v /var/lib/docker/containers:/var/lib/docker/containers:ro \-e ACCOUNT_UUID=<my-account-id> \-e REPOSITORY_UUID=<my-repository-id> \-e RUNNER_UUID=<my-runner-id> \-e OAUTH_CLIENT_ID=<my-oauthclient-id> \-e OAUTH_CLIENT_SECRET=<my-oauthclient-secret> \-e WORKING_DIRECTORY=/tmp \-e RUNTIME_PREREQUISITES_ENABLED=true \-e PAUSE_IMAGE="my-private-registry/my-pause:latest" \-e AUTH_PROXY_IMAGE="my-private-registry/my-auth-proxy:latest" \-e CLONE_IMAGE="my-private-registry/my-clone:latest" \--name my-runner-b0ae87b8-423b-5c24-9a95-84ddad9cdfae \docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runnerThe default Atlassian Docker images used by the self-hosted runners are:
PAUSE_IMAGE–docker-hub.packages.atlassian.com/google/pause:latestAUTH_PROXY_IMAGE–docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-auth-proxy:prod-stableCLONE_IMAGE–docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-dvcs-tools:prod-stable
All of the above default images can be retrieved usingdocker pull without logging in (they are public images).
If your server is behind a firewall, don’t forget toallowlist the domains you’d like to pull images from.
Use images from a private Docker registry
The Docker-based runner can be configured to pull versions of the public Atlassian docker images from a private docker registry that allows authentication using a username and password.
To use a private Docker image hosted on a Docker registry (such asDocker Hub), create or update the.docker/config.json file with login credentials for the Docker registry. The use of authentication credentials other than basic authentication (a username with a password), such as tokens and timed passwords is not supported. The use of acredential store is also not supported.
A.docker/config.json file can be created either by:
Using the Docker login command
To create or update the~/.docker/config.json file with login credentials:
On the runner host, run the following command and provide your username and password when prompted:
docker login <registry_hostname>If the login is successful, you will receive a warning about unencrypted storage of your password and the message
Login Succeeded.If you don't receive the warning, the docker instance on the host may be configured to usea credential store, which is not supported.
Mount the host
.docker/config.jsonfile in the runner container using the volume flag (-v), such as:-v <path_to_docker_config_directory>/.docker:/root/.dockerWhere the default location for
<path_to_docker_config_directory>/.dockeris~/.docker/.For example:
docker container run \-v /var/run/docker.sock:/var/run/docker.sock \-v /var/lib/docker/containers:/var/lib/docker/containers:ro \-v <path_to_docker_config_directory>/.docker/config.json:/root/.docker/config.json \-e ACCOUNT_UUID=<my-account-id> \-e REPOSITORY_UUID=<my-repository-id> \-e RUNNER_UUID=<my-runner-id> \-e OAUTH_CLIENT_ID=<my-oauthclient-id> \-e OAUTH_CLIENT_SECRET=<my-oauthclient-secret> \-e WORKING_DIRECTORY=/tmp \-e RUNTIME_PREREQUISITES_ENABLED=true \-e PAUSE_IMAGE="my-private-registry/my-pause:latest" \-e AUTH_PROXY_IMAGE="my-private-registry/my-auth-proxy:latest" \-e CLONE_IMAGE="my-private-registry/my-clone:latest" \--name my-runner-b0ae87b8-423b-5c24-9a95-84ddad9cdfae \docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner
Manually creating the Docker config.json file
To manually create or update the~/.docker/config.json file with login credentials:
On the runner host, use a plain text editor to create or open the
.docker/config.jsonfile in the user's home directory.Add or append the
authstop-level property, such as:{ "auths": { "my-private-registry-uri": { "auth": "dXNlcjpwYXNzd29yZA==" }, "my-other-private-registry-uri": { "auth": "dXNlcjE6cGFzc3dvcmQx" } }}Where
my-private-registry-uriandmy-other-private-registry-uriare the URLs of two private registries, such as Docker Hub. Theauthvalues are the username and password for registries (colon-separated) after they have beenbase64 encoded. To base64 encode the username and password on a macOS or Linux command line, run:echo -n 'user:password' | base64Mount the host
.docker/config.jsonfile in the runner container using the volume flag (-v), such as:-v <path_to_docker_config_directory>/.docker:/root/.dockerWhere the default location for
<path_to_docker_config_directory>/.dockeris~/.docker/.For example:
docker container run \-v /var/run/docker.sock:/var/run/docker.sock \-v /var/lib/docker/containers:/var/lib/docker/containers:ro \-v <path_to_docker_config_directory>/.docker/config.json:/root/.docker/config.json \-e ACCOUNT_UUID=<my-account-id> \-e REPOSITORY_UUID=<my-repository-id> \-e RUNNER_UUID=<my-runner-id> \-e OAUTH_CLIENT_ID=<my-oauthclient-id> \-e OAUTH_CLIENT_SECRET=<my-oauthclient-secret> \-e WORKING_DIRECTORY=/tmp \-e RUNTIME_PREREQUISITES_ENABLED=true \-e PAUSE_IMAGE="my-private-registry/my-pause:latest" \-e AUTH_PROXY_IMAGE="my-private-registry/my-auth-proxy:latest" \-e CLONE_IMAGE="my-private-registry/my-clone:latest" \--name my-runner-b0ae87b8-423b-5c24-9a95-84ddad9cdfae \docker-public.packages.atlassian.com/sox/atlassian/bitbucket-pipelines-runner
Limitations
This feature has the following limitations:
Authentication using acredential store is not supported. Only login using basic authentication (username and password) is supported.
The images must be hosted in a registry. The runner will always pull images from a remote host and can't use images on the host device.
This feature is only available to Docker self-hosted runners. Other runners (such as shell-based runners) don't use containers.
Was this helpful?
- Runners
- Configure logging in self-hosted runners
- Configure runner concurrency and inspect step queue
- IP addresses for runners behind corporate firewalls
Use your Docker images in self-hosted runners
- Autoscaler for Runners on Kubernetes