23

Internet speed prioritization in containers

How can I prioritize a container with regards to internet speed? Let's assume I've got two podman (docker) containers and both upload stuff.

Reasoning

My upload bandwidth is limited. One container needs to reliably upload stuff and the other doesn't. Thus, I want to prioritize one container over the over in order to deliver content in this container reliably.

Example

Syncthing can sync over a long time period but jellyfin can't.

all 8 comments
sorted by: hot top controversial new old
[-] Lem453@lemmy.ca 9 points 9 months ago
[-] GravitySpoiled@lemmy.ml 2 points 9 months ago

thx. If I read it correctly, you can set a bandwidth limit to a container, e.g. busybox. Can you prioritize as well?

[-] Lem453@lemmy.ca 2 points 9 months ago

I don't know. This docker allows you to use the standard Linux command tc on a docker container. Perhaps check to see if tc allows you to prioritize traffic like you. This isbgenerall called "quality of service". That search term may help as well.

[-] MangoPenguin@lemmy.blahaj.zone 5 points 9 months ago* (last edited 9 months ago)

This would be done in your routers QoS settings using the port to select traffic most likely, or if running the containers in macvlan networking mode, by IP.

[-] sudneo@lemmy.world 4 points 9 months ago

Cgroups have the ability to limit TCP and total network bandwidth. I don't know from the top of my mind whether this can be configured at runtime (I.e. via docker run), but you can specifcy at runtime the cgroup parent to use. This means you can pre-create the cgroup, set the limits and start the container with that parent cgroup.

You can also run some hook script after launch that adds the PID to a cgroup every time the container is launched, or possibly use tc.

I am not aware of the ability to only limit uplink bandwidth, but I have not researched this.

[-] GravitySpoiled@lemmy.ml 2 points 9 months ago

thx. docker-tc as suggested below does probably this. I'd like to prioritize, not only limiting.

[-] sudneo@lemmy.world 3 points 9 months ago* (last edited 9 months ago)

Yeah ultimately every container has it's own veth interface, so you can do shaping using tc on those.

Edit: I had a look at docker-tc. It does what you want, BUT. Unless your use case is complex, I would really think twice about running a tool written in bash which has access to the docker socket (I.e. trivial node escape) and runs with NET_ADMIN capability.

That's a lot of power to do something you can also do with a few lines of code executed after you start the container. Again, provided that your use case is not complex.

this post was submitted on 14 Mar 2024
23 points (96.0% liked)

Selfhosted

40767 readers
1635 users here now

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!

founded 2 years ago
MODERATORS