11

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

2
  • 1
    Please follow the Compose V2 installation guide or use docker-compose instead of docker compose. Commented Nov 15, 2021 at 22:57
  • I came across the problem which is on the opposite side: After installing Docker v20 which includes compose, "docker compose" works, "docker-compose" doesn't. Commented Apr 12, 2023 at 11:31

3 Answers 3

3

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/

Sign up to request clarification or add additional context in comments.

Comments

0

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

4 Comments

docs.docker.com/compose/cli-command "The new Compose V2, which supports the compose command as part of the Docker CLI, is now available. ... You can test the Compose V2 by simply replacing the dash (-) with a space, and by running docker compose, instead of docker-compose."
@ForrestKeppler oh I didn't know that existed! per the docs did you do this step? github.com/docker/compose-switch
Correct me if Im wrong but this switch is to translate 'docker-compose' statements into the new 'docker compose' But I need 'docker compose' translated into 'docker-compose' because I dont have docker desktop installed.
Any solution other than installing docker-desktop specifically yet?
0

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"
  ]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.