Docker

How to Fix the “docker-compose: command not found” Error

Docker-compose is a well-known development tool and a significant part of the Docker platform. It is used to build, manage, and share multi-container programs or applications. This platform introduced the concept of containerization. A simple container in Docker is built through Dockerfile. Moreover, the “docker-compose” specifies the simple YAML file to build and run containers.

This blog has demonstrated how to fix the “docker-compose: command not found” error.

How Does the “docker-compose: command not found” Error Occur?

Docker includes the Docker-compose utility with the installation of Docker-desktop for Windows or Mac. However, occasionally or in older Docker versions, docker-compose may not be installed along with Docker. As a result, when users run the “docker-compose” command, they may get the error “docker-compose: command not found”, as shown below:

How to Fix the “docker-compose: command not found” Error?

To resolve the specified error, install docker-compose separately using the below-stated instructions.

Step 1: Open Windows PowerShell
Launch the Windows PowerShell terminal as administrator from the Start menu:

Step 2: Set Security Protocol
Configure the PowerShell Security protocol “Tls12” through the mentioned command. This protocol must be followed to install Docker tools from the GitHub repository:

> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Step 3: Install Docker Compose
Next, install the Docker compose utility with the help of the given command:

> Start-BitsTransfer -Source "https://github.com/docker/compose/releases/download/v2.14.2/docker-compose-Windows-x86_64.exe" -Destination $Env:ProgramFiles\Docker\docker-compose.exe

The command will install the “docker-compose.exe” file in the “ProgramFiles\Docker” directory:

Step 4: Paste the “docker-compose.exe” in Docker “bin” Directory
Navigate the “ProgramFiles\Docker\” directory and cut the “docker-compose.exe” file with the help of “CTRL+X” key:

Next, open the “bin” directory of Docker by navigating the “ProgramFiles\Docker\Docker\resources\bin” and paste the “docker-compose.exe” file using the “CTRL+V” key:

Step 5: Verification
Lastly, verify whether the error has been resolved or not by executing the “docker-compose” command:

> docker-compose version

The output shows that we have successfully resolved the stated error:

OR:

We have offered a simple solution to resolve the “command not found: docker-compose” error.

Conclusion

To fix the “docker-compose: command not found” error, first, check if the “docker-compose.exe” file is installed or not along with Docker. If the Docker compose is not installed, open Windows PowerShell and configure the PowerShell Security protocol “Tls12”. After that, install the Docker Compose tool using the provided command in the above section. This blog has demonstrated how to resolve the “docker-compose: command not found” error.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.