Docker Community Forums

Share and learn in the Docker community.

What is the best way to create persist database container?


(Mikerob) #1

What is the best way in a developer environment to create a persist database container that can have its data persist between reboots? Using docker compose.


(Ralph Kincade) #2

this would be a volume this would be a the “-v” option

docker compose would require a YML file


(Mikerob) #3

Thank you for your quick reply. I want to see if I could create this setup using docker compose. What would be the correct syntax within compose’s YML file to have a volume persist to the host?


(Mohammedazfar2015) #4

Please try the below docker compose file for data persists sample


web:
build: .
command: bin/rails server --port 3000 --binding 0.0.0.0
ports:
- "3000:3000"
links:
- db
volumes:
- .:/myapp
volumes_from:
- bundle

bundle:
image: myapp_web
command: echo I’m a little data container, short and stout…
volumes:
- /bundle