podman-compose icon indicating copy to clipboard operation
podman-compose copied to clipboard

Enable usage of `--ansi never` argument to be support docker-compose based CLI syntax

Open nilsjha opened this issue 1 year ago • 2 comments

Libraries like Spring Boot have implementations for docker-compose CLI, which breaks when using podman-compose as a direct drop-in replacement. By drop-in, I've symlinked docker-compose to podman-compose . The library here (Spring) references the --ansi argument, which is present in docker-compose, but not in podman-compose.

See https://github.com/spring-projects/spring-boot/blob/74d69d0eb150d5f17e3715f225eb4f5809df9202/spring-boot-project/spring-boot-docker-compose/src/main/java/org/springframework/boot/docker/compose/core/DockerCli.java#L100

If having the support to specify --ansi never as an alternative to --no-ansi, the utilities will be more cross-compatible.

2024-11-27T20:27:15.988+01:00 ERROR 73685 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed

org.springframework.boot.docker.compose.core.ProcessExitException: 'docker compose --file /home/<project-dir>/compose.yaml --ansi never config --format=json' failed with exit code 2.

Stdout:
Stderr:
>>>> Executing external compose provider "/usr/local/bin/docker-compose". Please see podman-compose(1) for how to disable this message. <<<<

usage: docker-compose [-h] [-v] [--in-pod in_pod] [--pod-args pod_args]
                      [--env-file env_file] [-f file] [--profile profile]
                      [-p PROJECT_NAME] [--podman-path PODMAN_PATH]
                      [--podman-args args] [--podman-pull-args args]
                      [--podman-push-args args] [--podman-build-args args]
                      [--podman-inspect-args args] [--podman-run-args args]
                      [--podman-start-args args] [--podman-stop-args args]
                      [--podman-rm-args args] [--podman-volume-args args]
                      [--no-ansi] [--no-cleanup] [--dry-run]
                      [--parallel PARALLEL] [--verbose]
                      {help,version,wait,systemd,pull,push,build,up,down,ps,run,exec,start,stop,restart,logs,config,port,pause,unpause,kill,stats,images}
                      ...
docker-compose: error: argument command: invalid choice: 'never' (choose from help, version, wait, systemd, pull, push, build, up, down, ps, run, exec, start, stop, restart, logs, config, port, pause, unpause, kill, stats, images)
Error: executing /usr/local/bin/docker-compose --file /home/<project-dir>/compose.yaml --ansi never config --format=json: exit status 2

nilsjha avatar Nov 27 '24 20:11 nilsjha

Hi,

Spring Boot Docker Compose rely on the latest version of docker-compose that introduce a lot of new options

As a workaround, one can install the latest version of docker-compose (2.x)

podman compose command can delegate calls to docker-compose and spring-boot-docker-compose works like a charm.

Both podman-compose and docker-compose can be installed, podman compose can be driven to choose the one we want via environment variable (PODMAN_COMPOSE_PROVIDER) or via config file (containers.conf)

More info there:

$ man 2 podman-compose
$ man 5 containers.conf

Hope it helps, P.S.: It worked for me 🙂

gwallet avatar Dec 04 '24 12:12 gwallet

It would be nice if podman compose could support those flags. I am trying to get away from Docker completely.

dragetd avatar Jul 18 '25 11:07 dragetd