Search code examples
windowsdockerdocker-compose

Docker compose V2: unknown shorthand flag 'f' (windows)


I'm currently running docker desktop version 20.10.22 (build 3a2c30b, fresh install) on Windows (using wsl2), but docker compose commands with the -f flag do not work correctly. Since I'm using docker compose V2 (checked the option in the docker desktop settings), my commands are with a space instead of a hyphen. I get the following message when running any docker compose command using -f:

unknown shorthand flag: 'f' in -f See 'docker --help'.

Specifically, I'm running the FIWARE NGSI-LD tutorials. All docker compose commands that are used within those tutorials fail. The commands can be found in the services file for each tutorial. For example, a command that fails (saying that the -f flag does not exist) within the Short-Term-History tutorial is the following:

docker compose -f docker-compose/mintaka.yml -p fiware up -d --remove-orphans --renew-anon-volumes

The weird thing is that docker compose --help and docker compose --version both return the output from respectively docker --help and docker --version, as if it excludes the compose keyword. The output of the above command also refers to the standard docker help command instead of the docker compose help.

UPDATE: Docker excludes the compose keyword between docker and the rest of the command. Replacing compose with a random string of letters gives the same effect. It seems as if it cannot recognize the compose keyword.

The old docker-compose is not installed so that does not work either. Running which docker-compose returns the docker-compose.exe location, inside the .../Docker/resources/bin folder. Running which docker compose returns the location of docker.exe. The .../Docker/resources/bin folder is inside the path environment variable.

Does anybody know what the problem might be? I've searched countless websites but did not find any solutions for this problem yet.

Kind regards


Solution

  • I reinstalled docker desktop with the same installer (also same version) and this resolved the problem weirdly enough...

    The only difference between my old and new installation was that I already had wsl2 installed this time.