Pipelines that previously worked are now failing with docker: command not found
Asked by Eduardo Bueno:

We have a deploy step that runs the aws-ecs-deploy pipe and as of today, all pipelines started failing with error \`bash: docker: command not found\`

The base image sha is the same which discards the possibility that the image may have been changed.


Answers:
author: Patrik S
body: Hello [@Eduardo Bueno](/t5/user/viewprofilepage/user-id/5336603) and welcome to the Community!

Checking for the pipe [atlassian/aws-ecs-deploy](https://bitbucket.org/atlassian/aws-ecs-deploy/src/master/) I see it was last updated in September, so it's very unlikely that an update in the pipe is what has caused the error you are receiving in pipelines.

The "bash: docker: command not found" error is returned when the bash is not able to find the binary for the program you are trying to execute, in this case, the **docker** binary. There are multiple causes of this error which are discussed in detail in the article [Bitbucket Pipelines - Command not found error](https://confluence.atlassian.com/bbkb/bitbucket-pipelines-command-not-found-error-1267761733.html) , and for your particular case I think it's likely related to the *PATH* variable being modified.

The *PATH* variable contains all the directories where bash will check for the binaries when you execute a command. If you define a Workspace/Repository/Deployment env variable named PATH, it will overwrite the default PATH which can lead to errors when executing the commands because bash will not be able to find the binaries. In this case, I would suggest checking your [workspace/repository/deployment for any environment variable](https://support.atlassian.com/bitbucket-cloud/docs/variables-and-secrets/#User-defined-variables) named PATH, and if there's any, rename or remove the variable and try running the pipeline again.

If the error persists, I see you have access to a Premium workspace that is entitled to regular support, so you can open a ticket with us at <https://getsupport.atlassian.com/> and we can help to investigate further :)

Thank you, [@Eduardo Bueno](/t5/user/viewprofilepage/user-id/5336603) !

Patrik S

comments: author: Eduardo Bueno
body: Yeah I guess that is probably the cause but we can't find anything that could possibly be replacing the PATH.


author: Patrik S
body: Hello [@Eduardo Bueno](/t5/user/viewprofilepage/user-id/5336603) ,

In case you are using Linux docker self-hosted runners to run your pipeline build, this issue might be caused by a docker directory left behind from a previous pipeline run, which is causing the runner to fail when executing a new build.

What happens is that when the runner starts, the docker binary is automatically copied to the runner's temp directory. However, we have seen that in rare cases, a previous unsuccessful Runner setup can cause a docker directory to not be deleted from the runner's **temp** folder. Since the docker folder already exists, in the subsequent runs, the Runner fails to mount the new docker directory and the docker binary won't be present during the build. As pipes are essentially a docker container, when the runner tries to start the pipe container using the **docker run** command it fails to find the docker binary and throws the error bash: docker: command not found.

This is covered in more detail in the article ["docker: Command not found" error while running docker commands in self-hosted Runner](https://confluence.atlassian.com/bbkb/docker-command-not-found-error-while-running-docker-commands-in-self-hosted-runner-1206785605.html), where it also contains a Solution which is to **remove the docker folder from the runner tmp directory and start the runner again**.

You can try the solution proposed in that article and check if it solves the issue.

Thank you, [@Eduardo Bueno](/t5/user/viewprofilepage/user-id/5336603) !

Patrik S


Tags: aws

bitbucket-cloud

bitbucket-pipelines

cloud