Atlassian Bamboo with Docker Compose

Thomas Suebwicha
4 min readMay 14, 2021

--

Written July 14, 2020
Last Edited May 15, 2021

This guide will walk through the steps involved in setting up an initial instance of a Bamboo server instance inside a Docker container using docker-compose. Bamboo is Atlassian’s CI/CD tool, commonly compared with Jenkins. The software can be installed on a host machine running Linux, MacOS or Windows or alternatively inside a Docker container.

Server Configuration

A basic configuration for the Bamboo server, as recommended by Atlassian on the DockerHub page, is detailed inside the docker-compose file. The server data is bind-mounted inside a directory alongside the compose file.

version: "3.8"  
services:
server:
container_name: bamboo-server
image: atlassian/bamboo-server:7.0.4
ports:
- 54663:54663
- 8085:8085
volumes:
- ./server:/var/atlassian/application-data/bamboo
init: true # Recommended by Atlassian to properly reap zombie processes

After running with docker-compose up -d the server will be available at http://localhost:8085.

Software License Key

Bamboo is a paid offering, however Atlassian offers a trial license which is valid for 30 days. To redeem a code, go to the Atlassian license portal: https://my.atlassian.com/license/evaluation and generate a new key for Bamboo. In the Server ID field, enter the id shown on the startup screen on the server instance. The license must be redeemed within 90 days. Save the key in a text file for reference.

Figure 1: Generate License

Authorisation

The first screen shown on the server will ask for a license key. Enter the key obtained in the previous step and then click Express Installation.

Figure 2: http://localhost:8085

Bamboo will then ask to create the first admin user. It’s important to remember these credentials because at the moment, they’re the only way to log in. By default (in version 7.0.4) the username is bamboo.

Figure 3: Administrator User

Additional Steps

Docker in Docker

As Bamboo is deployed inside a Docker container, it shouldn’t have its own Docker daemon. The Bamboo server should access the Docker daemon from the host machine, so that when the local agent runs docker commands like docker run, the container is deployed as a sibling container on the host machine.

Installing Docker in Docker is the same for Bamboo as for any other CI/CD tool inside Docker. The docker.sock socket must be bind mounted to the Bamboo server container, the docker CLI must be installed to the server and the correct permissions must be given to the linux user which bamboo runs under (by default bamboo).

First, modify the compose file to include the bind mount.

docker-compose.yml

version: "3.8"services: 
server:
container_name: bamboo-server
build: ./
ports:
- 54663:54663
- 8085:8085
volumes:
- ./server:/var/atlassian/application-data/bamboo
- /var/run/docker.sock:/var/run/docker.sock # Bind mount docker.sock for Docker in Docker
init: true # Recommended by Atlassian to properly reap zombie processes

Note that the image section has changed to build. Next, create a Dockerfile to customise the Atlassian Bamboo image:

Dockerfile

FROM atlassian/bamboo-server:7.0.4
WORKDIR /home/bamboo/
ARG DOCKER_GID=1001
USER root
# Install Docker binaries
RUN curl -O https://download.docker.com/linux/static/stable/x86_64/docker-19.03.9.tgz \
&& tar -xzf docker-19.03.9.tgz \
&& rm docker-19.03.9.tgz \
&& mv docker/* /usr/bin/ \
&& rmdir docker
# Add bamboo to the docker group
RUN groupadd -g ${DOCKER_GID} docker \
&& usermod -aG docker bamboo
USER bamboo

The ARG DOCKER_GID must be set to the host machine’s docker GID. This can be found on the host machine by opening a Linux shell and entering the command

cat /etc/group | grep docker

Change the value 1001 in the Dockerfile to the value returned by the command.

Run the Bamboo server again with docker-compose build and docker-compose up -d (bringing it down first if not already done). There are some settings in Bamboo which need configuring to tell Bamboo where to find the docker command*.*

In Bamboo, click the settings icon in the top right corner and then Overview. On the left menu, under Build Resources select Server Capabilities and add a new capability for Docker.

Figure 4: Adding Docker capabilities

The Docker capability will be added to the Server Capabilities. Additionally, the Agents page shows that for the Default Agent (Local), the Docker capability has automatically been added. This is because the local agents run on the same machine (in the same container, using the same file system) as the server, so the binaries are shared.

The Bamboo build agent will now be capable of running Docker build steps, such as docker run, build and push.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

--

--

Thomas Suebwicha
Thomas Suebwicha

Written by Thomas Suebwicha

A developer wanting to share my knowledge and bring up others.

No responses yet

Write a response