7

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

Forrest Keppler
  • 577
  • 3
  • 7
  • 20
  • 1
    Please follow the [Compose V2 installation guide](https://docs.docker.com/compose/cli-command/#install-on-linux) or use `docker-compose` instead of `docker compose`. – Turing85 Nov 15 '21 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. – ulyssis2 Apr 12 '23 at 11:31

2 Answers2

1

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/

Forrest Keppler
  • 577
  • 3
  • 7
  • 20
-2

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

Diego Velez
  • 1,584
  • 1
  • 16
  • 20
  • 1
    https://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." – Forrest Keppler Nov 16 '21 at 00:52
  • @ForrestKeppler oh I didn't know that existed! per the docs did you do this step? https://github.com/docker/compose-switch/ – Diego Velez Nov 16 '21 at 16:36
  • 1
    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. – Forrest Keppler Nov 16 '21 at 20:59