Trying to implement Bamboo Agent running on docker container
Asked by shivaram:

Hi,

I'm trying to run bamboo agent on docker container. My server URL is in the format of https://\*\*\*\*\*.\*\*\*.com(Which is my application URL).My server is in a windows VM. I downloaded the agent base from <https://hub.docker.com/r/atlassian/bamboo-agent-base> .

When I try to run docker run command from the overview of bamboo agent base URL (mentioned above), The image got downloaded and my docker container is up.

1) When my docker container is up, how to connect this container to bamboo server?

2) I tried installing remote agent using [https://\*\*\*\*\*.\*\*\*\*\*.com/bamboo/admin/agent/addRemoteAgent.action](https://devtest.trapsoft.com/bamboo/admin/agent/addRemoteAgent.action) inside the docker container.

Result:

Agent process started, shutdown hook registered, proceeding with log pump...  
Running Bamboo Agent...  
Bamboo Agent is already running.  
Waiting for the agent process to finish...  
The underlying agent process terminated with a non zero exit code: 1  
The underlying agent process terminated with a non zero exit code: 1  
Bamboo Agent Installer is shutting down, the underlying agent process has already been shut down.

From this, How do I connect to the bamboo server. (I provided security token also).

3) How to install bamboo agent in docker windows container?

Regards


Answers:
author: Daniel Santos
body: Hi [@shivaram](/t5/user/viewprofilepage/user-id/3604506)

From what I can understand, the issue you are facing could be caused by networking misconfiguration issues. I'll try to share what I know in the hopes that it will help you move forward with this configuration.

* The agent is the one trying to connect with the Bamboo Server, not the opposite.  
  It will know where to look for the Server based on the last parameter of the docker run command e.g.:  

  ```
  docker run \
    -v bambooAgentVolume:/home/bamboo/bamboo-agent-home \
    --name="bambooAgent" \
    --init -d atlassian/bamboo-agent-base \
    BAMBOO_SERVER_URL
  ```

* We need to make sure the container is able to resolve the BAMBOO_SERVER_URL otherwise it will not be able to reach the server to follow next needed handshake steps.  
  In case the container is not able to resolve the https://\*\*\*\*\*.\*\*\*.com address provided, it may be worth trying to use the **host.docker.internal** as a reference to the Host IP of the server running the docker container (assuming this is the machine running Bamboo).  
* Once the agent is able to reach this server it will be noticed by the Bamboo Server which will answer with the Broker configuration. This configuration will be used to configure another communication channel using the JMS protocol.
* The broker configuration is available in **\<Bamboo_Server_Home\>/bamboo.cfg.xml.** You need to make sure that the address configured in **bamboo.jms.broker.client.uri**(inside bamboo.cfg.xml file) is resolvable and reachable from the agent container as well, otherwise, your agent will be stuck trying to reach the broker.

<br />

In this thread ([Solved: The docker images for Bamboo Server and Bamboo ...](https://community.atlassian.com/t5/Bamboo-questions/The-docker-images-for-Bamboo-Server-and-Bamboo-Client-Base-do/qaq-p/1181727?utm_source=atlcomm&utm_medium=email&utm_campaign=answer_accepted_as_solution&utm_content=topic)), you can find a simple example where we have both Bamboo Server and Agent running in different Docker containers. The magic is done by docker in that example which is able to make both containers see the same network and hostnames.

It might be the case that your problem is not related to the network config. To confirm we are in the right direction, can you please:

1. Make sure you stop the docker container running.
2. Start the docker container again.
3. check the container logs:  
   docker logs CONTAINER_NAME or CONTAINER_ID
4. Share what are the errors you see.

I'm asking for the logs because I'm not sure if the logs you shared are from the first start or a different attempt from inside the container.  

comments: author: shivaram
body: No problem.. everything's sorted. I have to edit the docker file a bit.. mention the bamboo agent.jar and path where i want it in the docker container correctly.


author: Daniel Santos
body: That is great! I'm glad you sorted it out!

Have a good one!


author: shivaram
body: Could we implement bamboo agent on windows docker container??


author: Daniel Santos
body: I'm assuming you are talking about a Linux remote agent container running on windows. It should work fine.