Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Accepted Answer
Hey there 👋
Great question! By default, Docker containers are ephemeral, meaning all data inside the container is lost when it’s removed. To persist data, you should use volumes.
Here’s a simple example:
docker run -v /my/local/path:/app/data your-image-name
This mounts a local folder (/my/local/path) on your Droplet to /app/data inside the container — so anything your container writes there will stay even if the container is removed or restarted.
If you’re using docker-compose, it looks like this:
volumes:
- ./data:/app/data
Also if you are just getting started with Docker, this free eBook might be helpful: 👉 https://github.com/bobbyiliev/introduction-to-docker-ebook
Hope that helps!
- Bobby
Heya, @1329f70102f4446f94457e686ea96f
I’ll also recommend to use volumes for this. The other option will be to use bind Mounts (Host Directory)
You can mount a directory from your host system directly into the container.
docker run -d \ --name mycontainer \ -v /path/on/host:/app/data \ myimage
This gives you full control and visibility of the files on the host machine.
⚠️ Be careful with permissions and SELinux/AppArmor when using bind mounts.
I’ll still however vote for volumes over bind mounts.
Regards