I'm using a Raspberry Pi 4B with a container based on a ROS2 image. I took about a month away from programming while working on a Pi-based NAS, and when I came back, the ROS2 container was gone. I checked Docker's recent activity and couldn't find any record of a removal command over the past couple of months. What could cause a stopped container to disappear, and how can I determine whether it was deleted or is simply no longer visible to Docker?
3 Answers
If Docker’s image and container lists look empty, check whether Docker’s data directory is on an external drive that failed to mount. On a Raspberry Pi, this is a common cause. Useful commands include `lsblk -f`, `blkid`, `df -h -T`, `findmnt`, and `cat /etc/fstab`. You can also inspect `/var/lib/docker/containers/`; directories with long hexadecimal names indicate that the container data may still exist but Docker is currently using a different data root.
First check whether the images and stopped containers still exist with `docker images` and `docker ps -a`. If the images are present but the container is missing, the most likely explanations are that it was started with `--rm`, which automatically deletes it when it stops, or that a cleanup command such as `docker system prune` removed it. A reboot during that time could also have triggered the issue if `--rm` was used. Docker Compose is a good way to keep the container definition in a permanent file so recreating it is easy.
The `--rm` option from tutorial commands is easy to overlook, so that may well be what happened.
Docker doesn’t keep an unlimited history of past events—`docker events` mainly reports activity while it is running—so not seeing a removal event doesn’t prove the container was never deleted. If the Docker directory is actually empty, other possibilities include an automated `docker system prune`, the container having been launched with `--rm`, or filesystem problems on the Pi’s SD card. Check for storage errors with `dmesg -T | grep -iE "ext4|i/o error"` and inspect `lost+found`. For the future, store the setup in a Compose file alongside the project so the container can be recreated easily.

I’ll check the drive and mount information. Sometimes there are so many possible causes that it’s hard to know where to start.