If you search in Google for Docker and Bamboo and skip the Atlassian links, then you will find numerous links on how to create a Docker container for a Bamboo remote agent. Nice to know but what is the advantage of doing that? A remote agent that can be started and destroyed quickly? But you are still limited to the number of remote agents allowed. In my opinion, there is a far more powerful way of using Docker with Bamboo.
The idea is simple: Run Docker *ON* your remote agent as a capability to run your build tasks in Docker containers. Development team should develop Docker containers for their software applications to run in. Then build and invoke these containers from within Bamboo. The advantages are numerous:
- All Bamboo agents have the same single dependency; Docker. This makes maintenance of the agents easier.
- There is no need anymore for any developer to access a remote agent directly. Use Docker containers to run your builds instead.
- Agents are used much more efficient because each agent can run any build plan since they only depend on Docker. No more team dependencies.
- It is easier to manage test state. Create a stateful Docker container and destroy it after the build. The new build run will start a new container with the exact same state.
- Developers have more control over their build plans since build configuration is now in the Dockerfile and is / can be version controlled. This immediately provides a solution to a missing feature in Bamboo: version control of build plans.
Although the idea is simple, the practical side has some implications. So far I have identified these actions that I have to do:
- Setup an internal Docker repository to store Docker containers. All builds should run from within a Docker container so we need a lot of containers! To name just a few: a maven container, a selenium container, a tomcat container, etc.
- Every task should run in a Docker container. Also Maven and Ant tasks. But with doing this, some of the features these tasks have in Bamboo are not usable. So I thought of wrapping some capabilities (e.g. the Maven capability) into a wrapper script that delegates the command to a Docker container.
- Developers need to learn Docker so they can build their own containers. To mitigate this risk, I think it is important to provide a decent amount of containers in the internal repository upfront.
- Bamboo comes with some tasks to build containers and run Docker. People need to learn this. Developers need to be aware of how to create and deploy Docker containers. All projects should now create a Docker container to run their project in.
Do you need help with your Bamboo instance?
Get in touch!