Summary
Docker run task fails with with /bin/sh: 0: Can't open /tmp/intialiseContainer.sh when running a detached container.
Expected Results
Task succeeds
Actual Results
The below exception is thrown in the build log:
error 28-Feb-2018 10:31:24 /bin/sh: 0: Can't open /tmp/intialiseContainer.sh error 28-Feb-2018 10:31:24 Error occurred while running Task 'Docker run' of type com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli. error 28-Feb-2018 10:31:24 com.atlassian.bamboo.task.TaskException: Failed to execute task error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.plugins.docker.service.RunService.execute(RunService.java:75) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.plugins.docker.tasks.cli.DockerCliTask.execute(DockerCliTask.java:70) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:285) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:224) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:285) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:112) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:71) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:203) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:175) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:122) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:117) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:126) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17) error 28-Feb-2018 10:31:24 at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41) error 28-Feb-2018 10:31:24 at java.lang.Thread.run(Thread.java:748) error 28-Feb-2018 10:31:24 Caused by: com.atlassian.bamboo.docker.DockerException: Error running Docker run command
Notes
- This bug strictly relates to Docker Tasks not Docker Runner builds (which can experience the same issue when setting up the container for the build). If you are seeing this issue in Docker Runner builds, please refer to BAM-19827: Docker Runner build will fail if the image used specifies a non-root user for the USER in the Dockerfile
Workaround
- Check the build log to see the exact command the docker run task is running and copy it to a Bamboo Script task instead of using a Bamboo Docker task. E.g.
/usr/bin/docker run --detach --name container-name image:latest