How to Fix “bash: docker: command not found” in Linux

When trying to run Docker in Linux, you may encounter the frustrating “bash: docker: command not found” error preventing you from running Docker commands.

This error indicates that even though Docker may be installed on your Linux system, there is an issue with your shell not being able to locate the Docker binaries and execute Docker properly.

In this comprehensive guide, we will cover the main reasons for the “bash: docker: command not found” error and the steps to troubleshoot and resolve this issue in Linux.

Main Causes of the Docker “Command Not Found” Error

Here are the most common reasons you may be getting the “bash: docker: command not found” error in Linux:

1. Docker is not installed – Docker may show as installed in your package manager but the binaries not be present on your system.

2. docker executable not in system PATH – The docker binaries may be installed but their location is likely not added to your system PATH variable correctly.

3. Permissions issue on docker executable – Even if docker binary is in PATH, a permissions error could prevent execution.

4. Docker service not started – The Docker service may fail to automatically start after package installation.

Understanding why this error occurs guides the troubleshooting process to identify the specific problem in your environment.

Now let’s go through various troubleshooting steps and methods for resolving the root issues:

Troubleshooting Steps to Fix Docker “Command Not Found”

Follow these key troubleshooting steps to diagnose which of the potential issues is causing the “docker: command not found” error on your Linux system:

1. Verify if Docker is Installed

First, we’ll check if the Docker package and relevant binaries are truly installed or if the error is arising from them missing entirely.

RPM-based systems (RHEL, CentOS, Fedora)

Check the docker package status with yum:

yum list installed | grep docker

Sample output if installed:

docker-ce.x86_64 3:20.10.12-3.el8 @docker-ce-stable

Debian/Ubuntu systems

Check the docker package status with apt:

apt list --installed | grep docker

Sample installed output:

docker-ce/now 20.10.12-0ubuntu2~20.04.2 amd64 [installed]

If no Docker package is reported as installed through your system package manager, then Docker is not yet set up on your machine.

You will have to install Docker first before being able to run docker commands or access the docker executable file location.

2. Check if Docker is Executable in Your System PATH

Next, we need to check if the location of the actual docker binary executable is present in your default system PATH variable used when running executables without fully specified location paths.

Display your current system PATH with the echo command:

echo $PATH

Common default paths for docker executable include:


If you do NOT see the path containing docker listed in your $PATH output, then the OS does not where know to find the docker executable, causing the “command not found” error.

We will need to append the actual docker path to the $PATH variable to resolve this.

3. Verify Permissions on Docker Executable

Even if the docker path is properly listed in the $PATH variable, a directory permissions error could still prevent successful execution.

Check read/execute perms on actual docker binary using ls:

ls -al /usr/bin/docker

Output with proper perms:

-rwxr-xr-x 1 root root 14314496 Feb 18 09:30 /usr/bin/docker

All users require at least read + execute permission on the binary to run docker commands. An error like this means a permissions tweak is still needed:

---------- 1 root root 14314496 Feb 18 09:30 /usr/bin/docker

4. Check if the Docker Service is Running

Finally, confirm if the Docker background service has started successfully after the initial package installation.

Check the docker service status with systemctl:

sudo systemctl status docker

Running service output:

docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2022-12-21 22:43:30 UTC; 2 months ago

A stopped service would show Active: inactive (dead) – indicating the service failed to start after package installation.

Now that we’ve diagnosed the potential issue causing the “docker: command not found”, we can move on to solutions.

5 Ways to Fix the “docker: command not found” Error

Based on which of the above issues is causing your Docker error, implement the corresponding fix:

1. Install Docker If Missing Entirely

If no Docker package showed as installed in Step 1, install Docker using your system package manager:

# Ubuntu/Debian 
sudo apt install

# RHEL/CentOS  
sudo yum install docker-ce

Then start the Docker service:

sudo systemctl start docker

And enable auto-start on reboot:

sudo systemctl enable docker

2. Add Docker Executable Path to $PATH Variable

If the docker executable is not found in your system path per Step 2, append the path manually:

Bash shell

Edit .bashrc file:

nano ~/.bashrc

Add path:

export PATH="$PATH:/usr/bin/docker"

Refresh modified PATH:

source ~/.bashrc

Zsh and other shells

Modify profile:

nano ~/.profile

Add path:

export PATH="$PATH:/usr/bin/docker"


source ~/.profile

Now verify docker path visibility:

echo $PATH

3. Fix Permissions on Docker Executable

If facing restricted permissions per Step 3, make the docker file executable by all users:

sudo chmod +rx /usr/bin/docker

Verify perms fix worked:

ls -al /usr/bin/docker

You should now see r-x read and execute enabled globally.

4. Manually Start the Docker Service

If you found the Docker service failed to start automatically per step 4:

Manually initiate the docker service:

sudo systemctl start docker

And enable auto-start on reboots:

sudo systemctl enable docker

5. Reinstall Docker if Other Fixes Fail

As a last resort, fully remove Docker and reinstall fresh if the above steps fail:

# Uninstall 
sudo yum remove docker-ce 
sudo rm -rf /var/lib/docker

# Reinstall
sudo yum install docker-ce

Be sure to restart your shell session or server instance to load changes across troubleshooting.

Once you have identified and resolved the specific issue through one of the above methods, docker and docker-compose commands should now properly execute without “command not found” errors when invocation from Bash or any shells!

Quick Docker Validation to Confirm Resolution

After applying any of the previous fixes to your system, confirm Docker is now functioning properly from the command line:

docker --version
# Example 
# Docker version 20.10.12, build e91ed57

And verify the ability to run containers:

docker run hello-world

# Expected output:
# Hello from Docker!
# This message shows that your installation appears to be working correctly.

No more errors indicate Docker is fully operational on your Linux machine!


In this guide, we covered the primary reasons you may encounter frustrating “docker: command not found” errors when trying to run Docker in Linux.

Whether due to Docker not being installed correctly, misconfigured paths, permission issues, or background service failures – various troubleshooting steps like checking $PATH variables, validating permissions, and manually starting docker service can identify and resolve the problem.

Be sure to fully uninstall and reinstall Docker as a last resort option if simpler fixes do not work.

I hope after following detailed troubleshooting and solution steps, you’ve conquered Docker “command not found” errors once and for all. Now you can get back to building containers and running Docker applications with operational confidence!

Leave a Comment