-1

So I am following the official documentation django with postgres in docker

https://docs.docker.com/compose/django/

I created another database, ( not using the default postgres db ). but when shutdown the server and re run it, It doesn't show the database. How can i create database so that it doesn't vanish when i shut down my docker server.

nani
  • 43
  • 3
  • Welcome to SO, your question doesn't show any code or docker config files, nor does it show any research on your part. Please read this to learn how to ask a good question on SO, here. https://stackoverflow.com/help/how-to-ask – Sahil Jan 29 '20 at 19:41

1 Answers1

1

All data in a container deleted when a container is destroyed or deleted. To save the data, you should save it in some mounted volume in docker. That volume will be on your machine. So all data which will be created during running of any process in that docker container will be stored in your machine. For this, you will have to understand Volume Api of docker.

Create a volume like this

docker volume create hello

And use that volume in your container like this

docker run -d -v hello:/world busybox ls /world

You can get further help from here.

Muhammad Hassan
  • 14,086
  • 7
  • 32
  • 54