Store permanent data into Droplets with Docker PostrgeSQL or using an external DB

Hi. I am new to deploying to DigitalOcean. I recently created a Droplet, into which I will put my Django API to serve my project. I saw that the droplet I rent has 25 GB of memory, and for the actual size of my project, it could be a good fit for the database. I run my entire code with Docker Compose, which handles Django and PostgreSQL. I was wondering if it is a good idea to store all the data in the PostgreSQL created by Docker Image, and stored in the local memory of the droplet, or do I need to set up an external Database in Digital Ocean?

Technically I think that could work, but I don’t know if it is safe to do, if I will be able to scale the droplets once the size scales, or if I will be able to migrate all the data into an external database, on digital ocean, a managed PostgreSQL all my data without too many problems.

And if I save it all locally, what about redundancy? Or can I clone my database on a daily basis in some way?

If someone knows about that and can help me, please I don’t know where to start

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Bobby Iliev
Site Moderator
Site Moderator badge
January 9, 2023

Hi there,

There are benefits to both approaches:

  • With a managed Postgres cluster, you don’t need to worry about backups, upgrades, optimization and etc.
  • With running Postgres on your Droplet directly, you would only need to pay for 1 Droplet.

If you decide to go with the Docker approach, I would recommend creating a Docker volume where you store your Postgres data, that way if you ever delete your Postgres container at least you would have your data stored in the Docker volume.

You could use pg_dump to backup your Postgres database on a daily basis and also enable backups for your Droplet itself:

No matter which option you choose, you could always migrate your database from the Docker container to a managed Postgres instance and vice-versa if you ever decide to!

Hope that this helps!



Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel