Docker Isolated Environment
Asked by joshysav:

Currently I am able to run docker containers as a docker task. Now I am trying to get a docker isolated environment working.

For some reason I am not able run a script task.

```
/tmp/runInDocker1101076931306272719.sh: 4: /tmp/runInDocker1101076931306272719.sh: /var/atlassian/application-data/bamboo/temp/SET-DOC-JOB1-13-ScriptBuildTask-7557055273167378877.sh: not found

```

My assumption is that the script is being created after the docker container has been created.

Would really appreciate the communities expertise


Answers:
author: joshysav
body: Hey Daniel,

I haven't had time to investigate this further. But essentially the issues kept arising whilst trying to use bamboo docker isolated environments whilst running a bamboo instance inside a container.

In the future I hope to revisit this issue. Thanks for your time!

comments: author: Daniel Santos
body: That is so strange, yeah, come back when you have time to investigate this.  
Thank you for your reply! =\]


author: Daniel Santos
body: Hi [@joshysav](/t5/user/viewprofilepage/user-id/56596)

I was able to reproduce this scenario by removing the **bamboo.tmp.directory** volume mounting point from the job docker runner configuration.  

I've opened this bug to report this issue:  
[\[BAM-20643\] Docker runner: removing bamboo.tmp.directory volume breaks job tasks.](https://jira.atlassian.com/browse/BAM-20643)  

If your problem is exactly the same, please try adding back the volumes needed for the right plan operation.  

Go to **Job configuration \>\> Docker \>\> Volumes** and make sure you have the following volumes configured:

```
|Host directory             |Container directory        |
|${bamboo.tmp.directory}    |${bamboo.tmp.directory}    |
|${bamboo.working.directory}|${bamboo.working.directory}|
```

Let me know if that fixes the issue.

comments: author: joshysav
body: Hey Daniel,

Thanks for taking the time to reply!

I had these volumes added. But still seem to getting this issue.

```
com.atlassian.bamboo.docker.DockerException: Error running Docker run command at com.atlassian.bamboo.docker.DockerContainerServiceImpl.run(DockerContainerServiceImpl.java:130) at com.atlassian.bamboo.v2.build.agent.docker.DockerContainerControllerImpl.startContainerIfRequired(DockerContainerControllerImpl.java:79) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:174) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:131) at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185) at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:125) at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:127) at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48) at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41) at java.lang.Thread.run(Thread.java:748)Caused by: com.atlassian.utils.process.ProcessException: Error executing /usr/bin/docker exec 68822519-8faa-4245-a2fd-962ec4f8a1e41507330 /tmp/initialiseContainer.sh at com.atlassian.bamboo.docker.DockerContainerServiceImpl.execute(DockerContainerServiceImpl.java:302) at com.atlassian.bamboo.docker.DockerContainerServiceImpl.execute(DockerContainerServiceImpl.java:273) at com.atlassian.bamboo.docker.DockerContainerServiceImpl.run(DockerContainerServiceImpl.java:127) ... 11 more
```


author: Daniel Santos
body: Hi [@joshysav](/t5/user/viewprofilepage/user-id/56596)

As your logs show the error is different now, which is progress.  
Investigating this new error I was able to find a bug:

* [\[BAM-19827\] Docker Runner build will fail if the image used specifies a non-root user for the USER in the Dockerfile](https://jira.atlassian.com/browse/BAM-19827)

Can you please confirm if the docker image you are using specifies a user different other then root in the docker file?  
This problem was fixed in 6.7.0. Can you share your Bamboo version?


author: joshysav
body: Thanks Daniel.

I am not specifying another user.

Bamboo version 6.9.2 build 60911


author: Daniel Santos
body: Hi [@joshysav](/t5/user/viewprofilepage/user-id/56596)  

Is docker runner working with other docker images?  
Would you mind checking this?  

We might be facing a different issue and isolating the problem will help us to understand what is causing it. It would be even better if we can reproduce it.


Tags: continuous-delivery

docker