Spinning up an instance or virtual machine may not always be necessary. Using a Docker container to replace an instance or VM is a saver on not only time, but resources. Having the ability to manage your entire Continuous Integration and Continuous Delivery (CICD) platform right from a container is ideal because you don't have to worry about spinning up extra resources. In your development environment, you can easily spin up Bamboo to test features and get started.

Prerequisties

  1. An understanding of Docker
  2. Docker installed on the operating system you're using. Installation instructions can be found here
  3. Docker version 19.03.5 or above
  4. Visual Studio Code which can be installed here

Preparing the environment

Switching to Linux containers

If you are on Windows, you will need to use Linux containers. The bamboo-server Docker image is built in Linux, so it can only be used with Linux containers. The difference between Windows images and Linux images is what operating system the Docker image was built on.

To switch to Linux or Windows containers on Windows, please follow this link

At the time of writing this, you cannot run Windows containers on OSX.

Pulling/cloning the Docker image

The first thing you will need to do is pull down the Docker image. Pulling down a Docker image means you are cloning the docker image to your local machine. This allows you to run the Docker image in a container to use Bamboo CICD.

The following command utilizes the Docker API to clone down the bamboo-server Docker image. The bamboo-server Docker image is what we will use to run Bamboo in a Docker container.

Let's open up a terminal and run the following command as you can see below;

docker pull atlassian/bamboo-server


Downloads will start to occur in your terminal. These downloads are happening from Docker Hub where your Docker image is being pulled from.

Creating Docker resources

We have cloned our Docker image and are ready to start creating the necessary resources for the Docker environment. Docker will need specific resources for your container to run. For example, a Docker volume may be needed to store persistent data. Because Docker containers are ephemeral, the data that you create in your Bamboo CICD server will be deleted once the container is deleted.

Creating a Docker volume

To create a Docker volume, let's utilize the docker volume create command. This command will create a Docker volume on our localhost. Once we run the command below, we will have a volume that our Bamboo Docker container can mount to.

docker volume create --name bamboo

We can also see the Docker volumes that are currently created if we run the docker volume ls command as shown below.

Running our Docker container for Bamboo CICD

Docker resources are now created. You are now ready to run your Bamboo CICD container. Once the container is run locally, you will have full access to Bamboo right from your localhost.

With the following command, you will have your container up and running. Let's go over what the parameters/switches are in this command;

  • docker run is to start the container locally
  • -v /data/bamboo:/var/atlassian/application-data/bamboo is the source volume and the destination volume. The source volume is the volume we created in the section Creating a Docker volume. The destination volume is where the volume will be inside of the container. Notice the : in the -v switch. To the left of the colon (:) is where the source volume is. To the right of the colon (:) is the destination on the container.
  • --name is the name of our container. Just like when you give your server a name
  • --init -d is to detach from your container. This means your container will continue to run even if you close your terminal.
  • -p is the source port and destination port. This means the port that we want our Bamboo server to be listening on and the destination port that you can use to access the container. These ports are the default ports for Bamboo, so your best bet is to keep them as is.
  • atlassian/bamboo-server is the image name that we will be using to create the container.

docker run -v /data/bamboo:/var/atlassian/application-data/bamboo --name="bamboo-server" --init -d -p 54663:54663 -p 8085:8085 atlassian/bamboo-server

Accessing the Bamboo CICD environment

In the previous section we saw how to create out Docker container. Now that our Docker container is up and running, we can access the Bamboo environment.

Open up a web browser of your choosing and go to localhost:8085

You will see a Bamboo UI ready for you to configure your environment.