1

I upgraded the Docker Compose to v2.18.1 but when I run docker compose command I get the docker: 'compose' is not a docker command. I am using Windows

I ran the command below to upgrade docker Compose

Invoke-WebRequest "https://github.com/docker/compose/releases/download/v2.18.1/docker-compose-Windows-x86_64.exe" -UseBasicParsing -OutFile $Env:ProgramFiles\Docker\Docker\resources\bin

This upgrade the docker compose to the v2.18.1.

enter image description here

But now when I use the docker compose ps command I get the error docker: 'compose' is not a docker command.

enter image description here

docker-compose ps command works

How do I upgrade the docker compose so that the commands work without " - " I am on Windows machine

1
  • please add the command you are using
    – Richard Seal
    Jun 7 at 18:05

3 Answers 3

0

I'm guessing you are typing in docker compose, this is not a valid command. Docker Compose is its own command use it like this:

docker-compose up

Note the hyphen, not the space!

1
  • When you upgrade to V2 version of Docker Compose the following command should work docker compose up -d. All docker compose command should work without the hyphen ex: docker compose version should work
    – Renuka
    Jun 7 at 18:17
0

Docker Compose v2 brings Compose's familiar functionality to the regular docker CLI. Instead of interacting with a separate docker-compose binary, you now use docker compose. Compose is integrated into Docker.

Compose v2 is included with Docker Desktop versions 3.4 and later. v2 became the default Compose version in v4.4.2.

I would recommend trying out the below steps.

  1. Ensure you are using Docker Desktop versions 3.4 and later.

  2. Use Docker Compose v2 checkbox in Docker Desktop’s settings page.

    enter image description here

v4.4.2 also aliases docker-compose to docker compose automatically. Compose v1 is inaccessible by default. You can disable this aliasing by running the docker-compose disable-v2 command or clearing the Use Docker Compose v2 checkbox in Docker Desktop's settings page. The docker-compose command will then revert to using Compose v1.

Reference: How to Upgrade to Docker Compose v2

Hope it helps!

0

As per the official docker documents, you need to update scripts to use Compose V2 by replacing the hyphen (-) with a space, using docker compose instead of docker-compose. For most projects, switching to Compose V2 requires no changes to the Compose YAML or your development workflow.

Docker recommends that you adapt to the new preferred way of running Compose V2, which is to use docker compose instead of docker-compose. This provides additional flexibility and removes the requirement for a docker-compose compatibility alias.

For more information, you should refer to the official docker documentation to migrate, and this will be helpful for you.

https://docs.docker.com/compose/migrate/

Still, if you don't want to use V2 then run the command docker-compose disable-v2 to disable V2.

But keep in mind that you can still download and install Compose V1 packages, but you won’t get support from Docker if anything breaks.

Hope this helps.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.