Describe the bug
When running podman-compose with the --dry-run flag, any network and volume referenced by service containers are still created. This violates the semantic of --dry-run which specifies no actions are performed.
To Reproduce
Steps to reproduce the behavior:
- place the MWE
compose.yaml file in a directory
- run
podman-compose -f compose.yaml -p test --in-pod false --verbose --dry-run up inside the directory
- observe that the network
test_srv and the volume test_testvol are created
MWE compose.yaml
services:
alpine:
image: docker.io/library/alpine:latest
networks:
- srv
volumes:
- testvol:/root
networks:
srv:
volumes:
testvol:
Expected behavior
No networks and volumes are created by podman-compose when invoked with --dry-run.
Actual behavior
Referenced networks and volumes are created by podman-compose when invoked with --dry-run.
Output
$ podman-compose version
podman-compose version 1.5.0
podman version 5.8.1
$ podman --version
podman version 5.8.1
$ podman-compose -f compose.yaml -p test --in-pod false --verbose --dry-run up
DEBUG:podman_compose:** excluding: set()
INFO:podman_compose:building images: ...
INFO:podman_compose:['podman', 'ps', '--filter', 'label=io.podman.compose.project=test', '-a', '--format', 'json']
INFO:podman_compose:creating missing containers: ...
DEBUG:podman_compose:podman volume inspect test_testvol || podman volume create test_testvol
INFO:podman_compose:['podman', 'volume', 'inspect', 'test_testvol']
INFO:podman_compose:['podman', 'volume', 'create', '--label', 'io.podman.compose.project=test', '--label', 'com.docker.compose.project=test', 'test_testvol']
INFO:podman_compose:['podman', 'volume', 'inspect', 'test_testvol']
INFO:podman_compose:['podman', 'network', 'exists', 'test_srv']
INFO:podman_compose:['podman', 'network', 'create', '--label', 'io.podman.compose.project=test', '--label', 'com.docker.compose.project=test', 'test_srv']
INFO:podman_compose:['podman', 'network', 'exists', 'test_srv']
INFO:podman_compose:podman create --name=test_alpine_1 --label io.podman.compose.config-hash=2d2fd0eb2c2ed7f13b7632cac115c549b272132083522daa6801c2cea3820495 --label io.podman.compose.project=test --label io.podman.compose.version=1.5.0 --label PODMAN_SYSTEMD_UNIT=podman-compose@test.service --label com.docker.compose.project=test --label com.docker.compose.project.working_dir=/home/sheaf/scratchpad/podman-tests --label com.docker.compose.project.config_files=test.yaml --label com.docker.compose.container-number=1 --label io.podman.compose.service=alpine --label com.docker.compose.service=alpine -v test_testvol:/root --network=test_srv:alias=alpine docker.io/library/alpine:latest
$ podman network ls -f name=test_srv
NETWORK ID NAME DRIVER
9ced48608379 test_srv bridge
$ podman volume ls -f name=test_testvol
DRIVER VOLUME NAME
local test_testvol
Environment:
- OS: Linux
- podman version: 5.8.1
- podman compose version: 1.5.0
Additional context
Note that the issue is still present on the latest commit ed3ec99. It appears that podman-compose unconditionally runs the necessary podman commands (seen with --verbose) to create networks and volumes even when --dry-run is passed. In contrast, docker-compose correctly skips the creation the referenced networks and volumes as seen below.
$ docker-compose version
Docker Compose version 5.0.2
$ DOCKER_HOST=unix://$XDG_RUNTIME_DIR/podman/podman.sock docker-compose -f compose.yaml -p test --verbose --dry-run up
[+] up 4/4
✔ Image docker.io/library/alpine:latest Pulled 0.3s
✔ Network test_srv Created 0.0s
✔ Volume test_testvol Created 0.0s
✔ Container test-alpine-1 Created 0.0s
end of 'compose up' output, interactive run is not supported in dry-run mode
$ podman network ls -f name=test_srv
NETWORK ID NAME DRIVER
$ podman volume ls -f name=test_testvol
DRIVER VOLUME NAME
Describe the bug
When running
podman-composewith the--dry-runflag, any network and volume referenced by service containers are still created. This violates the semantic of--dry-runwhich specifies no actions are performed.To Reproduce
Steps to reproduce the behavior:
compose.yamlfile in a directorypodman-compose -f compose.yaml -p test --in-pod false --verbose --dry-run upinside the directorytest_srvand the volumetest_testvolare createdMWE compose.yaml
Expected behavior
No networks and volumes are created by
podman-composewhen invoked with--dry-run.Actual behavior
Referenced networks and volumes are created by
podman-composewhen invoked with--dry-run.Output
Environment:
Additional context
Note that the issue is still present on the latest commit ed3ec99. It appears that
podman-composeunconditionally runs the necessary podman commands (seen with--verbose) to create networks and volumes even when--dry-runis passed. In contrast,docker-composecorrectly skips the creation the referenced networks and volumes as seen below.