avast / gradle-docker-compose-plugin

Simplifies usage of Docker Compose for integration testing in Gradle environment.
MIT License
413 stars 96 forks source link

composeUp FAILED: unknown shorthand flag: 'f' in -f #414

Closed joffrey-bion closed 1 year ago

joffrey-bion commented 1 year ago

When upgrading to version 0.17.2 of this plugin (using compose v2 by default), I get the following error:

:autobahn-tests:composeUp FAILED
unknown shorthand flag: 'f' in -f
See 'docker --help'.

Usage:  docker [OPTIONS] COMMAND

... // usual docker help follows

See this scan: https://scans.gradle.com/s/vzlatqx2dkhxy/console-log?task=:autobahn-tests:composeUp

It looks very much like this: https://github.com/docker/compose/issues/8986#issuecomment-1015065858

Maybe we need to make sure the -f options are specified before the up subcommand.

augi commented 1 year ago

Thanks for the report! I'm comparing the documentation of V1 and V2, and really, the difference is that in V1, -f is just one of the options, so it can be everywhere before up (we have it always before up). While in V2, -f is a special option that has to come first: https://docs.docker.com/engine/reference/commandline/compose/

augi commented 1 year ago

The proposed fix will be released in 0.17.4. Just please note that I saw this error also in an environment where Compose plugin wasn't installed.

joffrey-bion commented 1 year ago

Thanks a lot for the very quick action!

Just please note that I saw this error also in an environment where Compose plugin wasn't installed

That is actually a good point. On macOS runners in GitHub Actions, I install the Docker CLI using brew install docker and then run colima start to get a "docker" engine running. I used to install docker-compose as well as part of the brew command, but I figured that for Compose v2 I wouldn't need it. In fact, it turns out it is necessary, and actually requires a bit of config so docker registers docker-compose as a plugin:

brew install docker docker-compose

# Link the Docker Compose v2 plugin so it's understood by the docker CLI
mkdir -p ~/.docker/cli-plugins
ln -sfn /usr/local/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose

colima start
igorbolic commented 1 year ago

It would be also useful to have a note in documentation that Docker Compose should be installed as plugin for V2, instead of standalone, being docker compose works only for plugin installation, while standalone will still produce the same error as reported in this issue.

joffrey-bion commented 1 year ago

Indeed, I had to figure that out, and add the 2 lines in the script as you can see above. It would be nice to see something like this somewhere in the docs.

sunny-gupta-ind commented 11 months ago

Hi @augi I am using the latest version of this plugin i.e. 0.17.5 Still I am getting the same error:

[2023-12-02T13:29:23.589Z] > Task :container-tests:composeBuild FAILED

[2023-12-02T13:29:23.589Z] unknown shorthand flag: 'f' in -f

[2023-12-02T13:29:23.589Z] See 'docker --help'.

[2023-12-02T13:29:23.589Z] 

[2023-12-02T13:29:23.589Z] Usage:  docker [OPTIONS] COMMAND

[2023-12-02T13:29:23.589Z] 

[2023-12-02T13:29:23.589Z] A self-sufficient runtime for containers

[2023-12-02T13:29:23.589Z] 

[2023-12-02T13:29:23.589Z] Options:

[2023-12-02T13:29:23.589Z]       --config string      Location of client config files (default

[2023-12-02T13:29:23.589Z]                            "/home/ubuntu/.docker")

[2023-12-02T13:29:23.589Z]   -c, --context string     Name of the context to use to connect to the

[2023-12-02T13:29:23.589Z]                            daemon (overrides DOCKER_HOST env var and

I would appreciate if you could suggest a work around.