Forrest Keppler
Forrest Keppler

Reputation: 727

docker-compose is installed but docker compose is not recognized

Running docker compose up gives docker: 'compose' is not a docker command.

But docker-compose up works just fine.

What gives? I thought compose was supposed to be part of the docker cli now.

How can I run docker compose up and get the same/similar behavior as docker-compose up?

docker --version -> Docker version 20.10.10, build b485636f4b

docker-compose --version -> Docker Compose version 2.1.1

Upvotes: 11

Views: 24351

Answers (3)

fleveillee
fleveillee

Reputation: 55

You've installed docker and docker-compose independently. Compose is a Docker plugin. For Docker to find the plugin, it needs to know its location.

There are many ways to install docker-compose as a plugin, they are all documented in the docker Install the compose plugin documentation page. And yes, this is done automatically for you when you use Docker Desktop.

I prefer to install them separately and run the following commands to show docker where docker-compose is located. That also solves the problem. The following should work on most linux distros:

# Create your local docker config CLI plugins folder, if it doesn't exist
mkdir -p "$HOME"/.docker/cli-plugins

# Create a symlink to docker-compose in that folder
ln -s "$(which docker-compose)" "$docker_compose_plugin_file"

If you are using Homebrew on macOS, you can use the fix above or you can use the recommended solution indicated by running brew info docker-compose and looking at the caveat information.

==> Caveats
Compose is a Docker plugin. For Docker to find the plugin, add "cliPluginsExtraDirs" to ~/.docker/config.json:
  "cliPluginsExtraDirs": [
      "/opt/homebrew/lib/docker/cli-plugins"
  ]

Upvotes: 0

Forrest Keppler
Forrest Keppler

Reputation: 727

It's because I had docker installed not through docker desktop.

I was using a minikube for my docker daemon, and the basic docker cli. But the basic cli (installed through brew install docker) doesn't have docker compose, that's part of docker desktop.

You can find the rest of that info here:

https://docs.docker.com/compose/cli-command/

Upvotes: 3

Diego Velez
Diego Velez

Reputation: 1893

Docker (in the cli is docker) and Docker Compose (on the cli is docker-compose) are different things.

Docker is the engine where the containers run

Docker-compose is a manager or orchestrator for those containers

This means that you cannot do docker compose, the correct command is docker-compose

I think you're confused on the commands

the way to start a container using docker (only 1 container) is

docker run -ti ubuntu bash

On the other hand you can do the same with Docker compose but you need a docker-compose.yml file where all the configuration is written, then to start it is

docker-compose up

To sum up

Docker and docker compose are 2 different things. You can find more info here What is the difference between docker and docker-compose

Upvotes: 0

Related Questions