Docker Compose Command Not Found: 3 Possible Causes & Fixes

While using Docker Compose, one error that you might encounter is: "Docker Compose Not Found". This error might seem daunting at first glance; however, it usually points to a few common issues that are relatively straightforward to resolve.

In this blog post, we'll explore three common scenarios that trigger this error and provide fixes for each. Let's dive in!

#1 Wrong Docker Compose Command Line Syntax

One reason you might encounter the 'Docker Compose command not found' error is due to the use of incorrect Docker Compose command line syntax.

In Docker Compose V1, the command line syntax is docker-compose, with a hyphen (-) between 'docker' and 'compose'. However, for Docker Compose V2, the syntax depends on the installation method.

  • As a plugin: When installed as a plugin, Docker Compose V2 follows the docker compose syntax, where commands are issued with a space instead of a hyphen. For example, to check the version, you would use docker compose version.
  • As a standalone binary: If Docker Compose V2 is installed as a standalone binary, the command syntax shifts to using a hyphen (docker-compose), similar to V1's approach. 

For instance, if I install Docker Compose V1 and then use the command docker compose version to check the installed version—note that I'm using the V2 syntax—I receive a message stating: “docker: 'compose' is not a docker command,” as shown below:

docker compose --version command output

Conversely, after installing the Docker Compose Plugin (V2) and using the V1 command line syntax to check the Docker Compose version, I see the error: “Command 'docker-compose' not found,” as shown below:

docker compose version command output

Solution:

The fix is straightforward—check the version using both command line syntaxes, and continue with the syntax that successfully returns the Docker Compose version.

Note: Compose V1 stopped receiving updates in July 2023 and is no longer included in new Docker Desktop releases. Compose V2 has taken its place and is now integrated into all current Docker Desktop versions. For more details, review the migration guide to Compose V2.

#2 Docker Compose Not Installed

Another reason you might see the "Command Docker Compose Not Found" error is because you don’t have Docker Compose installed.

On macOS, Windows, and Linux, when you install Docker Desktop, Docker Compose comes bundled with it, so you don’t need to install it separately. However, the situation can differ on Linux. You may have installed Docker Engine and Docker CLI but not Docker Compose.  

Note: Although recent versions of Docker Engine for Linux have started to include Docker Compose as part of the Docker package (especially with the introduction of the Docker Compose V2), this isn't universally the case for all Linux distributions or installation methods. 

For example, on my Ubuntu system, I have Docker Engine and Docker CLI installed but not Docker Compose. So, if I check the Docker Compose version using the command docker compose version (Docker Compose V2 syntax), I get an error saying “docker: ‘compose’ is not a docker command,” as shown below:

docker compose version command output

If I check the version using the Docker Compose V1 syntax (docker-compose --version), I get the error: “Command ‘docker-compose’ not found,” as shown below:

docker compose --version command output

But how can we be sure that this error is because we don’t have Docker Compose installed and not for some other reason? Well, if we don’t find any result when searching for the Docker Compose binary, this means Docker Compose has not been installed.

You can run the command below to search your entire filesystem for the docker-compose binary:

sudo find / -name docker-compose

After running the command, if you don’t get any results, then Docker Compose is not installed on your system.

Solution:

The solution is straightforward—Install Docker Compose. You can find installation instructions for your specific Linux distribution here.

#3 Incorrect Path Configuration

Another common reason behind the "Command Docker Compose Not Found" error could be an incorrect PATH configuration. The PATH environment variable helps your operating system locate executables. If Docker Compose is installed in a non-standard location but not properly added to your PATH, your terminal won't be able to find and execute Docker Compose commands.

Solution

First, locate the installation directory of Docker Compose on your system using the following command: 

sudo find / -name docker-compose

Once identified, add this directory to your system's PATH environment variable. This ensures that your system can recognize and execute Docker Compose commands from any directory.

Note: Make sure that the path you add to the PATH variable points to the directory containing the docker-compose binary, not to the file itself. For example, if the full path to the docker-compose binary is /usr/local/bin/docker-compose, you should add /usr/local/bin to your PATH, not /usr/local/bin/docker-compose

Conclusion

In this blog post, we walked through three common causes behind the "Docker Compose Not Found" error and detailed the steps to resolve each. Now, you're equipped with the knowledge to troubleshoot this issue, whether it arises from incorrect Docker Compose command line syntax, missing Docker Compose installation, or incorrect PATH configuration.

Want to learn how to view logs for a multi-container application deployed via Docker Compose, so that you can troubleshoot when applications don’t run as expected? Check out our blog post: Docker-Compose Logs: How to View Log Output?

Interested in learning more about Docker? Check out the following courses from KodeKloud:

  • Docker for the Absolute Beginner: This course will help you understand Docker using lectures and demos. You’ll get a hands-on learning experience and coding exercises that will validate your Docker skills.  Additionally, assignments will challenge you to apply your skills in real-life scenarios.
  • Docker Certified Associate Exam Course: This course includes all the topics covered by the Docker Certified Associate Exam curriculum. The course offers several opportunities for practice and self-assessment. There are hundreds of research questions in multiple-choice format, practice tests at the end of each section, and multiple mock exams that closely resemble the actual exam pattern.