Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker container error: unknown flag: --build [closed]

After an update of Docker Desktop (on windows 11) from 4.34.0 4.34.2, trying to run:

docker compose up --build

results in this error: unknown flag: --build

Why is this happening?

like image 717
Chen Peleg Avatar asked Mar 12 '26 09:03

Chen Peleg


1 Answers

The error you're seeing is likely due to a change in how Docker Compose V2 handles flags after your update. In Docker Compose V2, the docker-compose command was integrated as a subcommand of the docker CLI (docker compose).

So basically, if docker compose up --build gives an error, try using the standalone docker-compose up --build. This should still work as expected.

You also want to check that you’re using Docker Compose V2 by running:

docker compose version

If you're on V2, try resetting Docker Desktop if the issue persists.

For more details, you can check the differences between Compose V1 and Compose V2 in the official documentation here: Docker Compose V2 Documentation

This should explain the issue and provide the correct approach.

like image 107
The DevOps Dude Avatar answered Mar 14 '26 00:03

The DevOps Dude