Using Docker images as build environments

Bitbucket Pipelines runs your builds in Docker containers. These containers run a Docker image that defines the build environment. You can use the default image provided by Bitbucket or get a custom one.

We support public and private Docker images from Docker Hub or your own registry.

Currently, Bitbucket Pipelines can't access registries that are hosted on private networks.

 


 

On this page

 


 

Default environment

If you don't specify an image, Bitbucket Pipelines will use the default one.

The default image has the following:  

 

platform applications available out-of-the-box
ubuntu 14.04
  • wget
  • xvfb
  • curl
  • git: 1.9.1
  • java: 1.8u66
  • maven: 3.0.5
  • node: 4.2.1
  • npm: 2.14.7
  • nvm: 0.29.0
  • python: 2.7.6
  • gcc: 4.8.4

The Docker image backing this environment is atlassian/default-image:latest.

 


 

Use existing environments

You can specify any public or private Docker image that's not hosted on a private network. 

Public images

You can use public images hosted by Docker Hub or in a self-hosted registry.

In the examples below:

  • The account name is the name of the account that owns the image.
  • The username, password, and email are your personal credentials.

 

  Images hosted by Docker Hub

 

If you don't specify the tag, Docker uses the latest version tag:

image: java
or 
image:
  name: java

 

An example of a Docker image configuration that uses a specific tag:

image: java:8u66
or 
image:
  name: java:8u66


If the image is not provided by Docker, but is hosted by Docker Hub, you must provide the Docker account details: 

image: account-name/java:8u66
or
image:
  name: account-name/java:8u66

 

  Images hosted outside Docker Hub

 

If the image is not provided by Docker and is hosted in a private registry, you must provide the registry details:

image: docker.your-company-name.com/account-name/java:8u66
or
image:
  name: docker.your-company-name.com/account-name/java:8u66

 

Private images

You can use private images hosted by Docker Hub or in a self-hosted registry. For each image, you must specify a valid username, an email, and a password.

We recommend using secured environment variables for sensitive information. For more information, see Environment variables.

 

  Images hosted by Docker Hub

 

If you don't specify the tag, Docker uses the latest version tag. A configuration example that uses variables:

image:
  name: java
  username: $USERNAME
  password: $PASSWORD
  email: $EMAIL

 

An example of a Docker image configuration that uses a specific tag:

 image:
  name: java:8u66
  username: $USERNAME
  password: $PASSWORD
  email: $EMAIL

 

If the image is not provided by Docker, but is hosted on Docker Hub, you must provide the Docker account: 

image:
  name: account-name/java:8u66
  username: $USERNAME
  password: $PASSWORD
  email: $EMAIL

 

  Images hosted outside Docker Hub

 

If the image is not provided by Docker and is hosted in a private registry, you must provide the registry details:

image:
  name: docker.your-company-name.com/account-name/java:8u66
  username: $USERNAME
  password: $PASSWORD
  email: $EMAIL

 


 

Create new environments

You can build your own Docker file and use it as your build environment. This way, you can keep your build environment very lightweight by only including the tools that you need in your build. 

Resources


 

1

 

Install Docker locally

 

 

https://docs.docker.com/engine/installation/

 

2

 

Build your own Docker image

 

 

https://docs.docker.com/engine/userguide/dockerimages/

 

3


Publish your Docker image to Docker Hub

 

 

https://docs.docker.com/engine/userguide/dockerimages/#push-an-image-to-docker-hub

 

4

 

Publish your Docker image to your self-hosted registry

 

 

https://docs.docker.com/engine/userguide/containers/dockerimages/#push-an-image-to-docker-hub

 


 

 

Was this helpful?

Thanks for your feedback!

Why was this unhelpful?

Have a question about this article?

See questions about this article

Powered by Confluence and Scroll Viewport