"docker: Command not found" error while running docker commands in self-hosted Runner

Still need help?

The Atlassian Community is here for you.

Ask the community

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:

bash: docker: command not found

Environment

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.

Solution

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

$ ls -l /tmp/<runner_uuid>

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

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

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

Copying Docker cli to working directory.

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

Last modified on Jan 26, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.