containers / containers/podman-compose

`down --volumes` option doesn't work when some services are specified

Open
#378 34 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
6.2k
Forks
622
PR merge metrics
No merged PRs in 30d

Description

`podman-compose down` has optional "services" argument:
```
usage: podman-compose down [-h] [-v] [-t TIMEOUT] [services ...]

positional arguments:
services affected services

optional arguments:
-h, --help show this help message and exit
-v, --volumes Remove named volumes declared in the `volumes` section of the Compose file and anonymous volumes attached to containers.
```
The problem:
**If _some_ (but not all) service(s) are specified, the --volumes option doesn't take place and no volumes get deleted:**

- Have two services: `sysroot` and `toolchain` and corresponding `sdk_*` volumes:
```
bam@Feedme:~/Develop/sdk$ podman container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
58a378218fc7 localhost/sdk_sysroot:latest /bin/sh -c echo P... About a minute ago Exited (0) 24 seconds ago sdk_sysroot_1
f3f48739ec72 localhost/sdk_toolchain:latest sh -c ccache -zs... About a minute ago Exited (130) 5 seconds ago sdk_toolchain_1

bam@Feedme:~/Develop/sdk$ podman volume ls
DRIVER VOLUME NAME
local sdk_KWinSrc
local sdk_Sysroot
local sdk_toolchain_e986ee6c24bb3c0b8d245e1917bac57930c3c466fc74708fc79a190cc9cf9930
```
- Remove them, one by one with `--volumes` option - no volumes get deleted actually:
```
$ podman-compose down --volumes sysroot
['podman', '--version', '']
using podman version: 3.2.1
** excluding: {'toolchain'}
podman stop -t 10 sdk_sysroot_1
sdk_sysroot_1
exit code: 0
podman rm sdk_sysroot_1
58a378218fc7b0ea2f9a8e66e388df17b69a95fcbd3047cf03d5ce7153d81fbc
exit code: 0

$ podman-compose down --volumes toolchain
['podman', '--version', '']
using podman version: 3.2.1
** excluding: {'sysroot'}
podman stop -t 10 sdk_toolchain_1
sdk_toolchain_1
exit code: 0
podman rm sdk_toolchain_1
f3f48739ec72a20b58d01eb965e34fbd8a36ddbac645f32b424f46a7e06a40d2
exit code: 0

bam@Feedme:~/Develop/sdk$ podman container ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

bam@Feedme:~/Develop/sdk$ podman volume ls
DRIVER VOLUME NAME
local sdk_KWinSrc
local sdk_Sysroot
local sdk_toolchain_e986ee6c24bb3c0b8d245e1917bac57930c3c466fc74708fc79a190cc9cf9930
```
- Specifying _all_ the services (or none of them) deletes the volumes, though:
```
$ podman-compose down --volumes sysroot toolchain
['podman', '--version', '']
using podman version: 3.2.1
** excluding: set()
podman stop -t 10 sdk_toolchain_1
Error: no container with name or ID "sdk_toolchain_1" found: no such container
exit code: 125
podman stop -t 10 sdk_sysroot_1
Error: no container with name or ID "sdk_sysroot_1" found: no such container
exit code: 125
podman rm sdk_toolchain_1
Error: no container with name or ID "sdk_toolchain_1" found: no such container
exit code: 1
podman rm sdk_sysroot_1
Error: no container with name or ID "sdk_sysroot_1" found: no such container
exit code: 1
['podman', 'volume', 'inspect', '--all']
podman volume rm sdk_KWinSrc
sdk_KWinSrc
exit code: 0
podman volume rm sdk_Sysroot
sdk_Sysroot
exit code: 0
podman volume rm sdk_toolchain_e986ee6c24bb3c0b8d245e1917bac57930c3c466fc74708fc79a190cc9cf9930
sdk_toolchain_e986ee6c24bb3c0b8d245e1917bac57930c3c466fc74708fc79a190cc9cf9930
exit code: 0

bam@Feedme:~/Develop/sdk$ podman volume ls
DRIVER VOLUME NAME
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.