Atlassian Bamboo with Docker Compose

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

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

Figure 1: Generate License

Authorisation

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

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.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Thomas Suebwicha

An entry developer wanting to share my knowledge and bring up others. Also an active person just trying to learn from other people mistakes.