I'm new to Docker and still getting used to Linux, and I'm struggling with how Docker interacts with the file system. I recently got my hands on a Raspberry Pi 5, and I've set up Docker on it. I created a `docker-compose.yml` file where I pulled a container and it's running my application just fine. In this setup, I've got a `config` directory that I mapped to a folder on my Raspberry Pi. The mapping in the yml looks like this: `./config:/config`, which connects the container's config to a subfolder near the yml file.
However, after I updated the application by pulling the latest image, it seemingly overwrote my configuration as if I had done a fresh install. While I can reconfigure it easily, I'm realizing I don't fully grasp how Docker operates with the local file structure. I assumed that since I'm keeping the configuration and files separate, updating the container would maintain the configurations intact. Can anyone suggest a straightforward guide or explain this in simple terms?
3 Answers
It would be helpful to see your entire Dockerfile to provide better insight. Are you clear on how that mounting path works? You're linking your Pi's `./config` to the container's root `/config` directory. If the application can’t pick up changes automatically after you update the files on your Raspberry Pi, you may need to restart the container for it to recognize those updates. This might be where the confusion is coming from.
Think of Docker's container file system like a stack of clear sheets. The base is your image (like Debian), and the Dockerfile adds layers for installs and files. When you run the container, there's a writable layer on top where changes are made. However, this layer is lost when the container is removed, which is why bind mounts are essential. With `./config:/config`, you're linking your Pi's filesystem to the container's, so your config stays put even after updates. Just a heads up, any data written to a path not mounted will be lost after removing the container, so don't forget to mount things like databases or logs too for persistence!
Check out this comprehensive Docker Compose guide I found. It covers the distinctions between bind mounts and volume mounts, plus different networking types in Docker. It's a long read, but really informative!
I appreciate this! I’m using my RPi to set up a small media server too and it’s just what I needed. I'm also trying out Portainer for monitoring. Gonna look into Dockge and Dozzle as well.

That guide is excellent! Thanks for sharing.