Cleaning UP Zombie Docker Containers

Cleaning UP Zombie Docker Containers

I brought my test stack back online this morning after a power drop. The metrics cluster came back up, the DHCP server looked fine, but when I started launching simulated users with my launch-from-mariadb.sh script, I hit container name conflicts.

First thing I checked, what’s running right now:

docker ps

That only showed this:

CONTAINER ID   IMAGE          COMMAND                  CREATED       STATUS             PORTS                                       NAMES
a2b821bb0677   redis:latest   "docker-entrypoint.s…"   2 weeks ago   Up About an hour   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp   goatsim-redis

So, Redis is running, nothing else active.

At that point I figured: there must be leftover containers from before the shutdown. If you just run docker ps, you won’t see them, that only lists running containers.

What you want is:

docker ps -a

That shows all containers, running, stopped, and exited.

That’s where I saw the problem:

c701c8e45da4   dhcp-pinger:latest   "/entrypoint.sh"         22 hours ago   Exited (255) 56 minutes ago                                               sim_user_0207

That’s a zombie container, it’s not running, but it still exists, so Docker won’t let you re-use the name.


Next step: how do you get rid of them cleanly? Simple:

docker container prune

This removes all stopped containers. It leaves your running containers and your images alone.

It ran for about a minute and gave me:

Deleted Containers:
c701c8e45da4
...

Total reclaimed space: 17.26MB

With that done, I re-ran my launcher script, this pulls active subscribers from MariaDB and spins up Docker containers to simulate user devices:

codexmcp@simuser-core-1:~/simusers/scripts$ bash launch-from-mariadb.sh
[+] Launching user_001 with MAC 02:DC:74:B4:25:9F
5787c3790ccecfe1f75c2814181258c24a84f183e86e0ad696dcc5f0ca6d3549

Now to confirm that traffic is hitting the DHCP server, I tailed the logs:

tail -f /var/log/remote/dhcp-core-1/kea-dhcp4.log

For anyone new to it:
tail -f means follow the end of the file live, it keeps the terminal open and shows you new log lines as they arrive.

In my case, these logs are being sent to a central logging server (logs-core-1):

2025-06-19T07:55:41.832011+00:00 dhcp-core-1 kea-dhcp4: INFO  [kea-dhcp4.dhcp4.132021658126016] DHCP4_QUERY_LABEL received query: [hwtype=1 02:f6:8f:ea:e4:b8], cid=[01:02:f6:8f:ea:e4:b8], tid=0x41454a45
2025-06-19T07:55:41.832103+00:00 dhcp-core-1 kea-dhcp4: INFO  [kea-dhcp4.packets.132021658126016] DHCP4_PACKET_RECEIVED [hwtype=1 02:f6:8f:ea:e4:b8], cid=[01:02:f6:8f:ea:e4:b8], tid=0x41454a45: DHCPDISCOVER (type 1) received from 0.0.0.0 to 255.255.255.255 on interface enp6s19

So now the simulated users are sending DHCP traffic, the server is responding, logs look good.


One issue left: no data showing yet on my Grafana dashboard (see image below).

No Data In Grafana

Next step: figure out why. Probably an OpenSearch or pipeline issue. I’ll dig into that and post the results next. Stay tuned.

--The Data Always Flows
-Bryan