"docker: Command not found" error in Bitbucket self-hosted runners

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

Summary

While running Pipeline builds in a Dockerized Self-hosted Runner, docker commands fail with the below error message:

1 bash: docker: command not found

Environment

Bitbucket Cloud. This article is pertinent to builds triggered on Dockerized Self-hosted Runners.

Diagnosis

This issue can be experienced while running any docker commands on a Dockerized Self-hosted Runner, for example, docker build.

This issue can be experienced by executing the docker command using the PATH, for example, /usr/bin/docker.

Cause

This issue is caused by the local Runner directory /tmp/<runner_uuid>/ already containing an empty docker folder. We are not yet sure why the Runner directory already has an empty docker directory. It might be due to a previous unsuccessful Runner setup.

Since the docker folder already exists, the Runner fails to mount the new docker directory and the docker binary won't be present during the build.

This is being tracked with our development team in the bug ticket below, please feel free to Watch this bug ticket and click This Affects My Team if you have encountered this issue (see: bug fix policy)

Solution

To resolve this issue, first confirm your local runner contains an empty docker folder:

1 $ ls -l /tmp/<runner_uuid>

Once you confirm the directory is already there, stop the Runner and remove the local folder:

1 $ rm -r /tmp/<runner_uuid>/docker

Restart the Runner and confirm that in the Runners' logs you can see the following message:

1 Copying Docker cli to working directory.

Builds triggered from now on will be able to run docker commands successfully.

Updated on March 5, 2025

Still need help?

The Atlassian Community is here for you.