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, 2023 at 18:05

3 Answers 3

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

For docker compose to work, you need to place downloaded docker-compose.exe file inside C:\Program Files\Docker\cli-plugins (Note that downloaded file has to be renamed.)

If cli-plugins does not exist, you can simply create a folder.

Overall you need this path to exist.

C:\Program Files\Docker\cli-plugins\docker-compose.exe

This way you will see both docker compose version and docker-compose version working. Hope this helps.

2
  • 1
    Thanks @Vikrant Punwatkar. Your solution worked in my case.
    – Archer
    Nov 28, 2023 at 3:00
  • Then no harm in upvoting :) It will help others landing on this question. Nov 28, 2023 at 9:51
-1

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 you have read our privacy policy.

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