Solving docker-compose: Command not Found Issue

DigitalOcean Referral Badge
Start your VPS now with FREE $100 credit.

Docker is widely used by developers to distribute their own software in a portable manner. Docker containers are industry-standard and contain all runtimes and libraries needed to run particular software.

Composing a container is also usually a straightforward process, the required docker-compose command is included in every installation of Docker, in any platform, be it Windows, Linux, or macOS.

However, in some cases, developers might run into the dreaded “docker-compose: Command not Found” response when trying to compose a container in a fresh install of Docker.

Table of Contents

What Caused the Issue?

The command not found error message was shown when trying to run docker-compose.
The command not found error message was shown when trying to run docker-compose. (Image: by @Subbu)

While docker-compose is a part of Docker installation, sometimes it was improperly installed and registered to the system.

Thus, when the command is invoked, the system will throw an error message instead. Thankfully, docker-compose can be installed with a few simple commands.

Quick info: How to fix Docker error processing tar file

The Solution

First, you will need to clean up the “incomplete” Docker installation by running this command:

sudo rm /usr/local/bin/docker-compose

And then, afterward, run this command:

sudo pip uninstall docker-compose

The first command removes the “incomplete” docker-compose binary, and the second command uninstalls it completely from your system. Now, after docker-compose is uninstalled, we can start reinstalling it with your distribution’s package manager system.

READ:  How To Install and Tuning Memcached on VestaCP CentOS 7 Running WordPress Site

Quick tip: Fixing ImportError: No Module Named Typing” error in pip

In this article, we are trying to reinstall docker-compose on a Raspbian system, so apt-get is used. Run this command to install python-pip and all its dependencies:

sudo apt-get -y install python-pip

During this process, python-pip package that is installed in your system will be reinstalled. python-pip itself is a repository of Python-based software, and from there, we can pull the latest version of docker-compose to install it in our system.

After python-pip is installed, run the following command to reinstall docker-compose:

sudo pip install docker-compose

Installing docker-compose through the python Pip repository is a more straightforward process compared to installing it from APT repositories or building it from the source itself.

After running this command, docker-compose will be installed from Pip repository and you can now start usingdocker-compose. Try to see the installed version with the following command:

docker-compose –version

The command will print the version of docker-compose that is installed on your system, and will look like this:

docker-compose version 1.16.1, build 6d1ac219

To sum up, problems ofdocker-compose can often be solved by removing the traces of “incomplete”docker-compose binaries and reinstalling them through the pip repository.

READ:  How is SSH Different from Telnet?

Users on systems based on Debian Linux (such as Ubuntu and Mint) can also add Docker’s repository to your sources.list and installdocker-compose through apt-get, though this practice is not recommended as adding a repository to sources.list can increase update time.

Leave a Comment