Persistent Data - Docker
See original GitHub issueThis is a great app! Thanks for all the hard work to make it possible. I have one issue that i am trying to resolve. I am running the babybuddy app via docker and I cannot make the data persistent between server restarts. What directories do I need to have as persistent volumes in order to get this to work?
This is my docker-compose file with the volumes I declare to create persistent data. What am I missing? Thanks!
docker-compose.yml
services:
db:
image: postgres
volumes:
- db:/var/lib/postgresql
app:
env_file: docker.env
build: .
command: gunicorn -c /app/gunicorn.py babybuddy.wsgi
volumes:
- baby_data:/app
ports:
- "8000:8000"
environment:
- VIRTUAL_HOST=**************
- LETSENCRYPT_HOST=**************
- LETSENCRYPT_EMAIL=**************
- VIRTUAL_PORT=8000
depends_on:
- db
networks:
- proxy-tier
- default
volumes:
baby_data:
db:
networks:
proxy-tier:
external:
name: webproxy
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Persist the DB - Docker Documentation
Persist the todo data · Create a volume by using the docker volume create command. · Stop and remove the todo app container...
Read more >Volumes - Docker Documentation
Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. While bind mounts are dependent on the directory ......
Read more >How to persist data in Docker: Volumes - TinyStacks
Volumes are the preferred mechanism for persisting data generated by and used by Docker containers, for the reasons given before .
Read more >Why Containers Miss a Major Mark: Solving Persistent Data in ...
Docker's solution. There is no getting away from it, data needs to be externalized and persisted outside the container and not maintained as...
Read more >Persist data in a container app using volumes in VS Code
Persist your todo data using named volumes · Create a volume by using the docker volume create command. · Under CONTAINERS, select getting-start ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for looking into it. I have figured it out. the postgresql db image uses /var/lib/postgresql/data as the default data location. In order to have a persistent db, you must use a named volume for this location. Additionally, in order to avoid re-migrating and collectingstatic content every time, I added /app as a named volume as well.
So for the default docker-compose, it would look like:
docker-compose.yml
I played around with this but unforntaley didn’t get anywhere either. Docker is a bit of a beast. I’ll leave this open for a bit and would love to hear if you manage to figure out proper config. Sorry I couldn’t be more helpful!