DEV Community

Cover image for Deploy multiple apps on a single VPS with Docker
Lukas Mauser
Lukas Mauser Subscriber

Posted on

Deploy multiple apps on a single VPS with Docker

The cost of virtual private servers (VPS) is low. You can rent a small box for about $5 per month. (Here you'll find some cheap VPS providers)

You get predictable pricing, high computing power, and with Docker it becomes super easy to run multiple applications on a single server.

But is it safe to run multiple apps on one machine using Docker? How many apps fit on a server? And what do you need to keep in mind?

TOC

Is it safe to run multiple apps on a single host?

Docker containers run pretty much isolated from each other and the host system. If you follow some basic security best practices, it can be considered safe to run multiple apps on a single host.

That being said, it's arguably riskier than running each application on a dedicated host. Outages and security breaches potentially affect multiple apps and their data.

The main issue that I experienced was single containers requiring all CPU and memory, and all other apps suffered from that.

It all comes down to the impact of potential failures. You probably don't need 99.999% uptime for a news aggregator or hobby project. And if you do not store important data, there is not much damage from data loss either.

This setup works well for:

  • low-stakes, low-traffic applications
  • background jobs
  • development environments
  • a homelab
  • indie hacking projects
  • internal tools
  • open source tools

Or in short: anything that does not need enterprise-grade uptime and security.

How many applications can you fit on a server?

It highly depends on your applications, obviously.

To give you a rough idea:

I have had a mixture of small websites, APIs, and databases (in total around 15 different applications) running on a VPS with 2GB RAM, 2 shared vCPUs, and 40GB disk for multiple months without issues.

This is one of the smallest machines my host offers, but to be fair, these apps are pretty lightweight, hardly get any traffic, and therefore barely require any resources.

You can run dozens of such small applications on a single server. On the other hand, a single app can overload your machine if it picks up traffic.

It is very hard to do estimates on resource consumption without data. But maybe some simple general wisdom is of any use to you:

  • more requests = more resources needed
  • heavy data = more resources needed. Piping images or videos through your server requires more CPU and memory than handling text or tiny JSON objects.
  • some algorithms require more resources than others, encryption or training AI models, for example.
  • applications (like databases) might allocate memory for buffers and caches and therefore consume a significant amount of RAM even though traffic might be low. Sometimes you can fine-tune them to run with fewer resources.

Challenges with hosting multiple apps on one server

In the most basic setup, all you need is access to a VPS, install Docker, and you are ready to roll!

Running multiple Docker apps on a single server becomes a bit more tricky once you flesh out the details. Here are some challenges I stumbled into:

  • How to keep an overview of debugging logs
  • How to prevent logs from eating all your disk space
  • Secrets management
  • How to get your apps and code changes onto the server (CI/CD)
  • Where to run the build process (requires quite a lot of resources)
  • Where to store Docker images
  • Access control if multiple people are involved
  • How to monitor server and application load
  • How to prevent images and Docker cache from eating all your disk space

If you are into learning DevOps, I encourage you to dive into the adventure and pull it off yourself. There is no better way to level up than to take action.

If you want to save yourself some hassle, there are some tools that make the job easier.

Tools to simplify running multiple apps on one machine

Sliplane

Sliplane is a fully managed container hosting solution that allows you to deploy multiple applications on a single server. If you don't want to deal much with DevOps at all, this is the fastest and easiest way to go. In comparison to other providers, it provides more high-level features and also includes domains, vertical scaling, SSL, security updates, and more. (Disclaimer: I co-founded the project)

Dokku

Dokku is an open-source PaaS alternative. It helps you set up a deployment pipeline and provides the tools to build and manage multiple applications. It also leverages Heroku Buildpacks in order to automatically detect your stack and deploy without Dockerfiles.

Portainer

Portainer, also available as open source, is designed as a container management platform. In comparison to Sliplane and Dokku, it does not take care of the build processes but comes with features to also manage more advanced cluster setups.

Comparison

Sliplane Dokku Portainer
Manage multiple containers
Take care of build process
Continuous deployments with "git push"
Dedicated build server
Manage multiple hosts
Open-source version?
User interface Web-based UI CLI Web-based UI
View container logs
View server metrics
Domain management
Manage clusters (Kubernetes, Docker Swarm)
Scale server
Automatic backups
Automatic security updates

Summary

Docker allows hosting multiple apps on a single server, making it a cost-effective solution for deploying small projects.

It is generally safe to use Docker to run multiple apps on a single server, but it should be limited to low-traffic, low-stakes applications.

Depending on what type of apps you run, you can fit dozens of projects on a single server.

If you want to dive deep into DevOps, you can go down the self-hosting route. Otherwise, there are tools like Sliplane, Dokku, and Portainer that simplify the process.

As a fully managed solution, Sliplane is the fastest and easiest way.

Dokku is open source. Its focus lies on making deployments easy with a simple "git push". The user interface is a CLI.

Portainer also provides an open-source version. In comparison to Sliplane and Dokku, it lacks a deploy pipeline. It comes with a web-based UI and offers some features to manage more advanced cluster setups.

Top comments (2)

Collapse
 
code42cate profile image
Jonas Scholz

Coolify is also pretty cool

Collapse
 
wimadev profile image
Lukas Mauser

Thanks for sharing! 🙏🏻