Open In App

How To Fix “Bash: Docker: Command Not Found” In Linux

Last Updated : 19 Mar, 2024
Improve
Improve
Like Article
Like
Save
Share
Report

Docker has become an essential tool for developers and system administrators to manage and deploy applications efficiently. However, encountering the error message “Bash: Docker: Command Not Found” can be frustrating, especially when you’re trying to work with Docker containers. In this guide, we’ll explore the potential causes of this error and provide step-by-step solutions to resolve it on Linux systems.

Understanding the Error:

When you see the error message “Bash: Docker: Command Not Found,” it means that the Bash shell cannot find the Docker executable in its path. This typically occurs when Docker is not installed properly or when its executable is not included in the system’s PATH environment variable.

"Bash: Docker: Command Not Found" in Red Hat

“Bash: Docker: Command Not Found” in Red Hat

"Command 'docker' not found" in Debain

“Command ‘docker’ not found” in Debain

Causes of the Error:

  • Docker Not Installed: If Docker is not installed on your system, attempting to run Docker commands will result in the “Command Not Found” error.
  • Incorrect PATH Configuration: Even if Docker is installed, the PATH environment variable may not be configured correctly to include the directory containing the Docker executable.
  • Permissions Issues: In some cases, permission restrictions may prevent the user from executing Docker commands.

Steps to Fix “Bash: Docker: Command Not Found” In Linux :

Install Docker:

If Docker is not installed on your system, you’ll need to install it first. Follow these steps based on your Linux distribution:

Ubuntu/Debian:

sudo apt update
sudo apt install docker.io

installing docker in debain

installing docker in debain

CentOS/RHEL:

sudo yum install docker

Installing Docker in Rhel/CentOS

Installing Docker in Rhel/CentOS

Arch Linux:

sudo pacman -S docker

Add Docker to PATH:

After installing Docker, you need to ensure that its executable is included in the system’s PATH environment variable. You can do this by adding the Docker binary directory to your PATH. Edit the .bashrc or .bash_profile file in your home directory and add the following line:

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

Save the file and reload the shell configuration:

source ~/.bashrc

Verify Docker Installation:

To verify that Docker is installed correctly and accessible from the command line, run the following command:

docker --version
successfully installed docker

successfully installed docker

Check Docker Permissions:

Ensure that your user account has the necessary permissions to execute Docker commands. You can add your user to the Docker group to grant the required permissions:

sudo usermod -aG docker $USER

Log out and log back in for the changes to take effect.

Restart Docker Service:

If Docker was installed but not running, you may encounter the “Command Not Found” error. Restart the Docker service to resolve this:

sudo systemctl restart docker

How To Fix “Bash: Docker: Command Not Found” – FAQs

What does the error “Bash: Docker: Command Not Found” mean in Linux?

This error indicates that the system cannot find the Docker command, meaning Docker is either not installed or its executable path is not included in the system’s PATH variable.

How do I install Docker on Linux?

To install Docker on Linux, you typically use the package manager specific to your distribution. For example, on Ubuntu, you can use apt with the command `sudo apt install docker.io`.

Why am I getting “Command Not Found” even after installing Docker on Linux?

This could happen if Docker’s executable path is not included in your system’s PATH variable. You might need to add it manually or restart your terminal session after installation.

How can I check if Docker is installed correctly on my Linux system?

You can check the Docker installation by running docker --version in your terminal. If Docker is installed correctly, it should display the version number of Docker installed on your system.

I’ve installed Docker, but I’m still getting “Command Not Found.” What should I do?

Ensure that Docker is installed properly and that the Docker daemon is running. Additionally, verify that the directory containing Docker’s executable file is added to your PATH environment variable. You might need to restart your terminal session after modifying the PATH variable.

Conclusion:

Encountering the “Bash: Docker: Command Not Found” error can disrupt your workflow, but by following the steps outlined in this guide, you can quickly diagnose and fix the issue on your Linux system. Whether it’s installing Docker, configuring the PATH environment variable, or adjusting permissions, these solutions will help you get Docker up and running smoothly, allowing you to continue working with containers effortlessly.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads