Docker task in a job running with Docker runner

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem 1: "<PATH>/docker: not found"

The build fails with:

1 2 3 4 5 6 7 8 simple 21-May-2018 11:42:35 Starting task 'Docker' of type 'com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli' command 21-May-2018 11:42:35 Beginning to execute external process for build 'Docker test - Default Job #3 (DT-DNF-JOB1-3)'\n ... running command line: \n/Users/user/atlassian/bamboo/6.5.0/install/temp/runInDocker2732808886495956167.sh /usr/local/bin/docker build --force-rm=true --tag=test /Users/user/atlassian/bamboo/6.5.0/home/xml-data/build-dir/DT-DNF-JOB1\n ... in: /Users/user/atlassian/bamboo/6.5.0/install/temp\n error 21-May-2018 11:42:35 /tmp/runInDocker7178378869512827680.sh: 4: /tmp/runInDocker7178378869512827680.sh: /usr/local/bin/docker: not found simple 21-May-2018 11:42:35 Failing task since return code of [/Users/user/atlassian/bamboo/6.5.0/install/temp/runInDocker2732808886495956167.sh /usr/local/bin/docker build --force-rm=true --tag=test /Users/user/atlassian/bamboo/6.5.0/home/xml-data/build-dir/DT-DNF-JOB1] was 127 while expected 0 error 21-May-2018 11:42:35 Error occurred while running Task '(1)' of type com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli. error 21-May-2018 11:42:35 com.atlassian.bam boo.task.TaskException: Failed to execute task error 21-May-2018 11:42:35 at com.atlassian.bamboo.plugins.docker.service.BuildService.execute(BuildService.java:53)

Problem 2: "Cannot connect to the Docker daemon at unix:///var/run/docker.sock"

The build fails with:

1 2 3 4 5 6 7 8 simple 21-May-2018 12:17:59 Starting task 'Hello-world' of type 'com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli' simple 21-May-2018 12:17:59 Running image name (hello-world) command 21-May-2018 12:17:59 Beginning to execute external process for build 'Docker test - Default Job #10 (DT-DNF-JOB1-10)'\n ... running command line: \n/Users/user/atlassian/bamboo/6.5.0/install/temp/runInDocker3551531651881180730.sh /usr/local/bin/docker run --volume /Users/user/atlassian/bamboo/6.5.0/home/xml-data/build-dir/DT-DNF-JOB1:/data --workdir /data --rm hello-world\n ... in: /Users/user/atlassian/bamboo/6.5.0/install/temp\n error 21-May-2018 12:18:00 /usr/local/bin/docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?. error 21-May-2018 12:18:00 See '/usr/local/bin/docker run --help'. error 21-May-2018 12:18:00 Error occurred while running Task 'Hello-world(2)' of type com.atlassian.bamboo.plugins.bamboo-docker-plugin:task.docker.cli. error 21-May-2018 12:18:00 com.atlassian.bamboo.task.TaskException: Failed to execute task error 21-May-2018 12:18:00 at com.atlassian.bamboo.plugins.docker.service.RunService.execute(RunService.java:75)

Workaround (Problems 1 and 2)

Avoid using docker runner for docker tasks:

  • In Plan configuration >> Stages >> (Affected Job) >> Docker, select Run this job in: Agent environment instead of the default Docker container option.*

  • Alternatively, a new Job can be created just to run docker tasks. This job will need to use the Agent environment runner instead of a Docker container.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.