Announcing support for Docker BuildKit in Bitbucket Pipelines

We are happy to announce that one of the top voted features for Bitbucket Pipelines, Docker BuildKit is now available. You can now build Docker images with the BuildKit utility.

With BuildKit you can take advantage of the various features it provides like:

  • Performance: BuildKit uses parallelism and caching internally to build images faster.
  • Secrets: Mount secrets and build images safely.
  • Cache: Mount caches to save re-downloading all external dependencies every time.
  • SSH: Mount SSH Keys to build images.

Configuring your bitbucket-pipelines.yaml

BuildKit is now available with the Docker Daemon service. It is not enabled by default and can be enabled by setting the environment variable DOCKER_BUILDKIT=1 in the pipelines configuration.

pipelines:
  default:
    - step:
        script:
          - export DOCKER_BUILDKIT=1
          - docker build --secret id=mysecret,src=mysecret.txt .
        services:
          - docker

To learn more about how to set it up please refer to the support documentation and for information on Docker Buildkit, visit: Docker Docs — Build images with BuildKit.

Please note:

  • Use multi-stage builds to utilise parallelism.
  • Caching is not shared across different builds and it’s limited to the build running on the same docker node where the build runs.
  • With BuildKit, secrets can be mounted securely as shown above.
  • For restrictions and limitations please refer to the restrictions section of our support documentation.