Its not about using docker for production environment.
As the DB is hosted in a container and not attached to any volume, once we delete the container (like docker rm <container_id>), the data in DB will be lost permanently.
Which will not be the way a production app should work.
Using this method, you can be safe in knowing that even if you accidentally run docker rm <container_id> that you can restart PostgreSQL again and have all of you data just as you left it previously.
Hope this helps!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Its not about using docker for production environment.
As the DB is hosted in a container and not attached to any volume, once we delete the container (like
docker rm <container_id>
), the data in DB will be lost permanently.Which will not be the way a production app should work.
I agree with Marcos...nice article J Shree! :-)
It might also be helpful to show folks how to save their data even after running
docker rm <container_id>
. This is how I normally accomplish this:First, create a local directory to hold the data:
Then start PostgreSQL using a volume mount so the container will store the data in this newly created local directory:
Using this method, you can be safe in knowing that even if you accidentally run
docker rm <container_id>
that you can restart PostgreSQL again and have all of you data just as you left it previously.Hope this helps!