Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discussion] containers+systemd : usage of podman quadlet #486

Closed
frotinybo opened this issue Dec 21, 2023 · 2 comments
Closed

[Discussion] containers+systemd : usage of podman quadlet #486

frotinybo opened this issue Dec 21, 2023 · 2 comments
Labels
documentation Improvements or additions to documentation

Comments

@frotinybo
Copy link

Hello,

This post is to discuss how I used podman quadlet to setup the container+systemd support of invidious.

I first integrated invidious through its container form. The docker-file/docker-compose material provided within the project is great and allowed a quite straight forward integration.

Next step was to fully integrate the service within my host, meaning:

  • starting/stopping the containers at boot/halt of the host.
  • regularly restarting the invidious container as mentioned in the documentation (memory leaks).

My container ecosystem being Podman, I decided to use a quite new tool for running Podman containers under systemd: quadlet. With quadlet, you describe how to run a container in a format that is very similar to regular systemd unit files. Resulting service files are then crunched by systemd as any other service files. I also used an intermediate tool named podlet. Podlet automatically generates quadlet files from different inputs, including a docker-compose file.

Transformation :
(podman-compose + invidious docker compose file) → (systemd + quadlet files)
using podlet to generate the output quadlet data from the input invidious docker compose file.

The transformation needed some small troubleshooting:

Podlet preprocessing:

Docker/podman compose performs some hidden tricks that are not straight forward translated in “the quadlet world”. Concerning invidious, I had to investigate network related problems , solved by modifying the input compose file :

  • to explicit the internal network between the two containers (invidious and invidious-db).
  • to explicit the invidious-db container hostname (used by the invidious container to connect to the db).

invidious docker-compose.yml :

services:
...
invidious:
...
networks:
- invidious-net

invidious-db:

hostname: invidious-db
networks:
- invidious-net

...

networks:
invidious-net:

Podlet processing (tool version 0.2.2)

“mkdir podletdir”
“podlet --overwrite --file podletdir --install compose docker-compose.yml”

This generates 3 files, one for each container (invidious, invidious-db) plus one for the network, files directly understood by systemd (but a “systemctl reload”) when placed under $HOME/.config/containers/systemd/ (podman rootless use case).

Podlet postprocessing:

I instructed systemd to stop the invidious container every hour by editing the invidious container quadlet file.

invidious.container quadlet file :

[Service]
Restart=always
RuntimeMaxSec=3600

Doing so, systemd will stop the container every hour and because of the existing Restart=always directive, systemd will restart the service as soon as it it stopped = effective restart of the container every hour.

Et voila. I now have a invidious service supported by an effective container+systemd combo.

Thanks to the invidious authors and contributors. This project is awesome.

@unixfox unixfox transferred this issue from iv-org/invidious Dec 21, 2023
@unixfox
Copy link
Member

unixfox commented Dec 21, 2023

If you don't want this to get lost into the github issues, you should contribute to the community installation guide here: https://github.com/iv-org/documentation/blob/master/docs/community-installation-guide.md

There is already a guide for podman. Make sure to keep a good structure.

@unixfox unixfox added documentation Improvements or additions to documentation and removed feature-request labels Dec 21, 2023
@unixfox unixfox closed this as completed Dec 21, 2023
@daniilgoss
Copy link

daniilgoss commented Apr 19, 2024

@frotinybo Greetings! I've been trying to achieve the same setup (Invidious + Quadlet). Would you kindly share your configuration files so we can understand how to structure/replicate in our environments? Thank you in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

3 participants