Run Docker commands in Bitbucket Pipelines
Bitbucket Pipelines allows you to build a Docker image from a Dockerfile in your repository and to push that to a Docker registry, by running Docker commands within your build pipeline. Dive straight in – the pipeline environment is provided by default and you don't need to customize it!
Enable access to Docker
To enable access to Docker daemon, add the following option to your bitbucket-pipelines.yml
options: docker: true
- mount the Docker CLI in your build container
- run and provide your build access to a Docker daemon
You can verify this by running
pipelines: default: - step: script: - docker version options: docker: true
You can check your bitbucket-pipelines.yml file with our online validator.
Available Docker commands
Inside your Pipelines script, you can run the following Docker commands:
See the Docker command line reference for information on how to use these commands. Other commands, such as
docker run, are currently forbidden for security reasons on our shared build infrastructure.
Note that if you've been running commands against your own Docker daemon, this new feature doesn't prevent you from continuing to do that.
Authenticate when pushing to a registry
To push images to a registry, you need to use
docker login to authenticate prior to calling
For example, add this to your pipeline script:
docker login --username $DOCKER_USERNAME --password $DOCKER_PASSWORD