podman-compose
podman-compose copied to clipboard
Executing podman-compose down doesn't remove network
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind feature
Description
When executing sudo podman-compose down
, the network is not removed.
Steps to reproduce the issue:
- Create docker-compose.yaml
mkdir dns-test;
cd dns-test;
rm docker-compose.yaml 2> /dev/null || true
cat <<EOT >> docker-compose.yaml
services:
app:
hostname: app.dns-test
image: busybox
command: httpd -f -p 8080 -h /etc/
db:
hostname: db.dns-test
image: busybox
command: httpd -f -p 8080 -h /etc/
EOT
- Podman-compose up
sudo podman-compose up -d;
['podman', '--version', '']
using podman version: 3.4.2
** excluding: set()
['podman', 'network', 'exists', 'dns-test_default']
['podman', 'network', 'create', '--label', 'io.podman.compose.project=dns-test', '--label', 'com.docker.compose.project=dns-test', 'dns-test_default']
['podman', 'network', 'exists', 'dns-test_default']
podman run --name=dns-test_app_1 -d --label io.podman.compose.config-hash=123 --label io.podman.compose.project=dns-test --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=dns-test --label com.docker.compose.project.working_dir=/home/glenn/dns-test --label com.docker.compose.project.config_files=docker-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=app --net dns-test_default --network-alias app --hostname app.dns-test busybox httpd -f -p 8080 -h /etc/
8a892599027f9aa0c7c2f2ba1862a37965974a724695b2685d0ee1c3f14d8d24
exit code: 0
['podman', 'network', 'exists', 'dns-test_default']
podman run --name=dns-test_db_1 -d --label io.podman.compose.config-hash=123 --label io.podman.compose.project=dns-test --label io.podman.compose.version=0.0.1 --label com.docker.compose.project=dns-test --label com.docker.compose.project.working_dir=/home/glenn/dns-test --label com.docker.compose.project.config_files=docker-compose.yaml --label com.docker.compose.container-number=1 --label com.docker.compose.service=db --net dns-test_default --network-alias db --hostname db.dns-test busybox httpd -f -p 8080 -h /etc/
f139a9a11ab1331401639b4a3899417daf20f7b4804876e77279ca9aa1e989cf
exit code: 0
- Podman-compose down
sudo podman-compose down;
['podman', '--version', '']
using podman version: 3.4.2
** excluding: set()
podman stop -t 10 dns-test_db_1
dns-test_db_1
exit code: 0
podman stop -t 10 dns-test_app_1
dns-test_app_1
exit code: 0
podman rm dns-test_db_1
f139a9a11ab1331401639b4a3899417daf20f7b4804876e77279ca9aa1e989cf
exit code: 0
podman rm dns-test_app_1
8a892599027f9aa0c7c2f2ba1862a37965974a724695b2685d0ee1c3f14d8d24
exit code: 0
- Podman network ls
sudo podman network ls;
Describe the results you received:
- Network still exists
NETWORK ID NAME VERSION PLUGINS
2f259bab93aa podman 0.4.0 bridge,portmap,firewall,tuning
84870f95be9b dns-test_default 0.4.0 bridge,portmap,firewall,tuning,dnsname
Describe the results you expected:
- Network is removed
NETWORK ID NAME VERSION PLUGINS
2f259bab93aa podman 0.4.0 bridge,portmap,firewall,tuning
- Example docker-compose
docker-compose down
Stopping dns-test_db_1 ... done
Stopping dns-test_app_1 ... done
Removing dns-test_db_1 ... done
Removing dns-test_app_1 ... done
Removing network dns-test_default
Additional information you deem important (e.g. issue happens only occasionally):
Output of podman version
:
Version: 3.4.2
API Version: 3.4.2
Go Version: go1.16.7
Built: Thu Jan 13 11:15:49 2022
OS/Arch: linux/amd64
Output of podman info --debug
:
host:
arch: amd64
buildahVersion: 1.23.1
cgroupControllers: []
cgroupManager: cgroupfs
cgroupVersion: v1
conmon:
package: conmon-2.0.29-1.module+el8.5.0+12582+56d94c81.x86_64
path: /usr/bin/conmon
version: 'conmon version 2.0.29, commit: 0f5bee61b18d4581668e5bf18b910cda3cff5081'
cpus: 4
distribution:
distribution: '"rhel"'
version: "8.5"
eventLogger: file
hostname: localhost.localdomain
idMappings:
gidmap:
- container_id: 0
host_id: 1000
size: 1
- container_id: 1
host_id: 100000
size: 65536
uidmap:
- container_id: 0
host_id: 1000
size: 1
- container_id: 1
host_id: 100000
size: 65536
kernel: 4.18.0-348.el8.x86_64
linkmode: dynamic
logDriver: journald
memFree: 7120764928
memTotal: 12373340160
ociRuntime:
name: runc
package: runc-1.0.2-1.module+el8.5.0+12582+56d94c81.x86_64
path: /usr/bin/runc
version: |-
runc version 1.0.2
spec: 1.0.2-dev
go: go1.16.7
libseccomp: 2.5.1
os: linux
remoteSocket:
path: /run/user/1000/podman/podman.sock
security:
apparmorEnabled: false
capabilities: CAP_NET_RAW,CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
rootless: true
seccompEnabled: true
seccompProfilePath: /usr/share/containers/seccomp.json
selinuxEnabled: true
serviceIsRemote: false
slirp4netns:
executable: /usr/bin/slirp4netns
package: slirp4netns-1.1.8-1.module+el8.5.0+12582+56d94c81.x86_64
version: |-
slirp4netns version 1.1.8
commit: d361001f495417b880f20329121e3aa431a8f90f
libslirp: 4.4.0
SLIRP_CONFIG_VERSION_MAX: 3
libseccomp: 2.5.1
swapFree: 6874460160
swapTotal: 6874460160
uptime: 8h 9m 30.72s (Approximately 0.33 days)
plugins:
log:
- k8s-file
- none
- journald
network:
- bridge
- macvlan
volume:
- local
registries:
search:
- registry.fedoraproject.org
- registry.access.redhat.com
- registry.centos.org
- docker.io
store:
configFile: /home/glenn/.config/containers/storage.conf
containerStore:
number: 0
paused: 0
running: 0
stopped: 0
graphDriverName: overlay
graphOptions: {}
graphRoot: /home/glenn/.local/share/containers/storage
graphStatus:
Backing Filesystem: xfs
Native Overlay Diff: "true"
Supports d_type: "true"
Using metacopy: "false"
imageStore:
number: 9
runRoot: /run/user/1000/containers
volumePath: /home/glenn/.local/share/containers/storage/volumes
version:
APIVersion: 3.4.2
Built: 1642068949
BuiltTime: Thu Jan 13 11:15:49 2022
GitCommit: ""
GoVersion: go1.16.7
OsArch: linux/amd64
Version: 3.4.2
Package info (e.g. output of rpm -q podman
or apt list podman
):
podman-3.4.2-9.module+el8.5.0+13852+150547f7.x86_64
Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
yes
Additional environment details (AWS, VirtualBox, physical, etc.):
VirtualBox
I can confirm this. podman-compose does not try to remove the default network it created.
This also makes the behaviour with regards to DNS name resolution (CNI plugin "dnsname") more confusing, because even after installing the plugin name resolution will not work until the network has been manually removed. When running podman-compose up
afterwards it is recreated with the dnsname
plugin and name resolution works.
We are seeing the same. We noticed volumes are also not removed.
Regarding volumes, just like docker-compose you must pass -v
Thanks, @muayyad-alsadi, I wasn't aware of the -v
argument to remove volumes! When trying it, I am seeing the following error:
-> podman-compose -f dev/docker/test.yml -v down
['podman', '--version', '']
using podman version: 3.4.2
podman-composer version 1.0.3
podman --version
podman version 3.4.2
exit code: 0
Error: "docker_test" has associated containers with it. Use -f to forcibly delete containers and pods: network is being used
Do I need to use two commands, the first to delete containers and the second with -v
to delete volumes? Or should it be possible in a single command?
Thanks!
@l3ender you typed the wrong command: -v
must be after the down
The command you typed is like this:
$ podman-compose --file dev/docker/test.yml --version down
The correct command should look like
$ podman-compose --file dev/docker/test.yml down --volumes
Or if you like short options (I don't for this reason 😉)
$ podman-compose -f dev/docker/test.yml down -v
This still is the case with the most recent release in the AlmaLinux9 appstream. I believe it also to be wrapped up with this issue: https://github.com/containers/podman/issues/20396, where the result is that the network isn't cleaned up and aardvark-dns gets "stuck". Nuking the aardvark-dns process from orbit after doing podman-compose down
is the easiest fix.
Client: Podman Engine
Version: 4.6.1
API Version: 4.6.1
Go Version: go1.19.10
Built: Wed Sep 27 13:20:12 2023
OS/Arch: linux/amd64```
It may or may not be related, I sometimes also see the network still not being removed (rootless podman btw), sometimes when i try a docker-compose run
, it will run fine but it doesn't give me the prompt back and it hangs. then i need to start a fresh ssh connection and kill the process.
Also, if I docker-compose up
, sometimes it will never exit after I press ^C
to stop it, the containers get removed but not the network and again i need to kill the process in a fresh session