[Bamboo Knowledge Base]
Manage and run your Bamboo remote agents using Docker!
A Bamboo server can use one or more remote build agents (up to 100 depending on your license). Remote agents execute jobs from your build plan. Because jobs can have different requirements, it is useful to have agents with different capabilities.
Docker is a great way to manage your remote agents, and provides:
Atlassian has published two images to the Docker Hub at https://registry.hub.docker.com/repos/atlassian/:
atlassian/bamboo-java-agent | Suitable for java stack development. |
|
atlassian/bamboo-base-agent | Suitable for deep customization. |
|
You can modify these images to suit your own requirements.
Note that the Docker images do not include a Bamboo server. Download and install Bamboo separately before continuing – see Getting started with Bamboo.
For a new Bamboo installation there will not be any remote agents yet. When you run a remote agent (see below), it will connect to the Bamboo server and will be ready to execute jobs from your build plans.
Ensure your Bamboo server is running.
Once the server is running go to Administration > Agents. This is where you'll see your remote agent once you run it.
The following commands need to be run with sudo
because Docker needs to run as root. You may need to replace docker
with docker.io
(depending on your installation) – see http://docker.io.
Pull the remote build agent from the Docker Hub Repository:
sudo docker pull atlassian/bamboo-java-agent
Once downloaded, run your agent with the following command:
sudo docker run -e HOME=/root/ -e BAMBOO_SERVER=http://hostname:port/bamboo -i -t atlassian/bamboo-java-agent:latest
Replace hostname:port
with your Bamboo server's name and port (typically 8085).
Don't use localhost
as the server address because for Docker, localhost
is in the Docker container, not the host machine.
Go back to Administration > Agents (or refresh that page) and notice that your remote agent has registered itself.
The two Bamboo agent images are based on our own atlassian/ubuntu-minimal image, which is built using the Docker 'contrib' script and 'debootstrap'.
To customise an image, run it in a container. Name the container for easier access later:
sudo docker run --name="tmp-name" -e HOME=/root/ -i -t atlassian/bamboo-java-agent:latest /bin/bash
Now change whatever you want inside the container with the usual bash commands. You can enforce some capabilities by changing the file in /root/bamboo-agent-home/bin/bamboo-capabilities.properties
.
After that, exit and create a new image from the container like this:
sudo docker commit tmp-name atlassian/customized-agent:1.0.0
You can publish your new image by pushing it to the Docker Registry.
If you have DNS problems (i.e. the Docker container can ping the IP of the server but not the hostname) consider using this command:
sudo docker run –dns=your-dns-server-ip1 –dns=your-dns-server-ip2
You'll need to replace those values with the actual IP addresses of your DNS server.
If the agent seems to connect and start bootstrapping but has trouble with active mq then check on your Bamboo server that you have set up the broker URL correctly. Go to Administration > General configuration. You should not have 'localhost' specified there.