docker is not recognized as an internal or external command

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# docker is not recognized as an internal or external command

The error "'docker' is not recognized as an internal or external command, operable program or batch file" occurs for 2 main reasons:

  1. Not having Docker installed on your machine.
  2. Not having Docker added to your PATH environment variable.

docker is not recognized as internal or external command

The easiest way to install Docker and add it to your PATH environment variable is to:

  1. Open the Docker page and click on the "Docker Desktop for Windows" button to download the installer.

click download docker for desktop

  1. Start the installer and click on the "OK" button.

start docker installer

  1. You will likely have to restart your PC as shown in the following screenshot. Click on the "Close and restart" button.

docker click close and restart

  1. After your PC has been restarted, open CMD and issue the docker --version command to make sure Docker is installed successfully.
shell
docker --version

issue docker command

  1. If you didn't have to restart your PC, make sure to close and then reopen CMD before using the docker command. This is necessary for your PATH environment variable to update.
If you get a permissions error when running a Docker command, start CMD as an administrator and then run the command.

To open CMD as an administrator:

  1. Click on the Search bar and type CMD.

  2. Right-click on the Command Prompt application and click "Run as administrator".

run cmd as administrator

If the "'docker' is not recognized as an internal or external command, operable program or batch file" error persists, you have to add Docker to your PATH manually.
  1. Click on the Search bar and type "docker".

  2. Right-click on "docker" under "Command" and click "Open file location".

search docker

  1. Select the location of the docker executable and copy it.

copy docker location in explorer

For me the location is C:\Program Files\Docker\Docker\resources\bin and it will likely be similar to your path.

We are looking for the directory that contains the docker.exe (executable) file.
  1. Click on the Search bar, type "Environment variables" and then click on "Edit the system environment variables".

edit system environment variables

  1. Click on the "Environment Variables" button.

click environment variables

  1. In the "System variables" section, select the "Path" variable and click "Edit".

select path and click edit

  1. Click "New" and paste the path to the Docker executable that you previously copied.

  2. You can use the "Move Down" button to move the Docker path to the bottom if it gets added at the top.

  3. Click on "OK" twice to confirm the changes.

  4. Close your Command prompt application and then reopen it.

Note that you must restart your Command prompt shell for the changes to take effect.

You might also have to restart your PC, but that's not always necessary.

After restarting CMD, issue the docker --version command to make sure Docker is installed and configured properly.

shell
docker --version

issue docker command

# Conclusion

To solve the error "'docker' is not recognized as an internal or external command, operable program or batch file", make sure:

  1. You have Docker installed on your machine.
  2. You have Docker added to your system's PATH environment variable.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.