Hi, I’m just getting started with Docker, so apologies in advance if this seems silly.

I used to self-host multiple services (RSS reader, invoicing software, personal wiki) directly on a VPS using nginx and mariadb. I messed it up recently and am starting again, but this time I took the docker route.

So I’ve set up the invoicing software (InvoiceNinja), and everything is working as I want.

Now that I want to add the other services (ttrss and dokuwiki), should I set up new containers? It feels wasteful.

Instead, if I add additional configs to the existing servers that the InvoiceNinja docker-compose generated (nginx and mysql), I’m worried that an update to Invoiceninja would have a chance of messing up the other setups as well.

It shouldn’t, from my understanding of how docker containers work, but I’m not 100% sure. What would be the best way to proceed?

@mudeth@lemmy.ca
creator
link
fedilink
English
210M

That would be ideal, per my understanding of the architecture.

So will docker then minimize the system footprint for me? If I run two mysql containers, it won’t necessarily take twice the resources of a single mysql container? I’m seeing that the existing mysql process in top is using 15% of my VPS’s RAM, I don’t want to spin up another one if it’s going to scale linearly.

@scorpionix@feddit.de
link
fedilink
English
010M

AFAIK it won’t and should you still get a bottleneck you can limit the maximum resources a service may use.

bjorney
link
fedilink
English
310M

it won’t necessarily take twice the resources of a single mysql container

It will as far as runtime resources

You can (and should) just use the one MySQL container for all your applications. Set up a different database/schema for each container

@mudeth@lemmy.ca
creator
link
fedilink
English
110M

I’m getting conflicting replies, so I’ll try running separate containers (which was the point of going the docker way anyway - to avoid version dependency problems).

If it doesn’t scale well I may just switch back to non-container hosting.

bjorney
link
fedilink
English
110M

To elaborate a bit more, there is the MySQL resource usage and the docker overhead. If you run two containers that are the same, the docker overhead will only ding you once, but the actual MySQL process will consume its own CPU and memory inside each container.

So by running two containers you are going to be using an extra couple hundred MB of RAM (whatever MySQL’s minimum memory footprint is)

@moonpiedumplings@programming.dev
link
fedilink
English
4
edit-2
10M

If I run two mysql containers, it won’t necessarily take twice the resources of a single mysql containers

It’s complicated, but essentially, no.

Docker images, are built in layers. Each layer is a step in the build process. Layers that are identical, are shared between containers to the point of it taking up the ram of only running the layer once.

Although, it should be noted that docker doesn’t load the whole container into memory, like a normal linux os. Unused stuff will just sit on your disk, just like normal. So rather, binaries or libraries loaded twice via two docker containers will only use up the ram of one instance. This is similar to how shared libraries reduce ram usage.

Docker only has these features, deduplication, if you are using overlayfs or aufs, but I think overlayfs is the default.

https://moonpiedumplings.github.io/projects/setting-up-kasm/#turns-out-memory-deduplication-is-on-by-default-for-docker-containers

Should you run more than one database container? Well I dunno how mysql scales. If there is performance benefit from having only one mysqld instance, then it’s probably worth it. Like, if mysql uses up that much ram regardless of what databases you have loaded in a way that can’t be deduplicated, then you’d definitely see a benefit from a single container.

What if your services need different database versions, or even software? Then different database containers is probably better.

@mudeth@lemmy.ca
creator
link
fedilink
English
110M

Thank you for an excellent explanation and blogpost. I’m getting conflicting answers, even on this question, but most authoritative sources do backup what you’re saying re:FS. I’m trying to wrap my head around how that works, specifically with heavy processes. I’m running on a VPS with 2 GiB of RAM and mysql is using 15% of that.

At this point I have my primary container running. I guess I’ll just have to try spinning up new ones and see how things scale.

What if your services need different database versions, or even software? Then different database containers is probably better.

This version-independence was what attracted me to docker in the first place, so if it doesn’t work well this way then I may just replace the setup with a conventional setup and deal with dependency hell like I used to - pantsseat.gif.

Create a post

A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.

Rules:

  1. Be civil: we’re here to support and learn from one another. Insults won’t be tolerated. Flame wars are frowned upon.

  2. No spam posting.

  3. Posts have to be centered around self-hosting. There are other communities for discussing hardware or home computing. If it’s not obvious why your post topic revolves around selfhosting, please include details to make it clear.

  4. Don’t duplicate the full text of your blog or github here. Just post the link for folks to click.

  5. Submission headline should match the article title (don’t cherry-pick information from the title to fit your agenda).

  6. No trolling.

Resources:

Any issues on the community? Report it using the report flag.

Questions? DM the mods!

  • 1 user online
  • 191 users / day
  • 419 users / week
  • 1.14K users / month
  • 3.85K users / 6 months
  • 1 subscriber
  • 3.71K Posts
  • 74.6K Comments
  • Modlog