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?
- How many applications can you fit on a server?
- Challenges with hosting multiple apps on one server
- Tools to simplify running multiple apps on one machine
- Summary
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 (17)
Coolify is also pretty cool
Thanks for sharing! 🙏🏻
Dokploy is comparable to Vercel and Netlify
Good one!
Yeah, UI looks pretty similar
Any idea how that compares to coolify?
such an info!, thank you very much for sharing.
You are very welcome! :-)
Really cool to see this method gaining traction, I’ve been using Træfik on Hostinger VPS to deploy my side projects. Its great fun.
Traefik-Docker combi is a great choice! :-)
Hi, thank you for this post. I have a problem, and I would like to know, if you have a solution. I have set up a Ubuntu server, where I would like to run Mattermost server and Immich server. If I set them up only one or another, it's working great. But when I set up both of them at the same time, I get connection issues. Even they are both idle, it takes about 30 seconds to connect to one or another, and they are not usable.
I have installed Immich with Docker compose, and Mattermost with Mattermost Omnibus.
Do you have a solution?
Sounds like your server might not be strong enough to handle both. Immich and Mattermost seem to be quite heavy on RAM. From what I found, Immich recommends 6GB, Mattermost recommends min 2GB. Very likely they allocate a big portion of these resources even in idle state.
Solution might be upgrading to a bigger server or running 2 servers.
Yes, the server wasn't strong enough. I have changed to a more powerful server, and now, everything works fine.
Thank You
Right!! 🏠 Why have 15 apps on 15 servers when you can juggle 15 apps on one server? Just need to be prepared, if one app decides to play diva and hog all the CPU and RAM. 🎭
Anyhow - what are the preparations for that case?
A good point to start is to limit resources with Docker.
If nothing else helps, jump on the server and try to shut down the bad actor ;)
Lovely! Thanks!
It's really awesome.
I did not know about sliplane.io/ It sounds interesting and I will check it out eventually! TY