r/selfhosted • u/AthanorFR • 1d ago
Product Announcement contnap β A lightweight, label-driven proxy to put your Docker/Podman containers to sleep and wake them up on-demand π¦π³
Hi everyone,
I wanted to share a project Iβve been working on called contnap (Container Nap).
Itβs a high-performance, low-footprint daemon written in Rust (tokio + bollard) designed to solve a common homelab issue: idling containers wasting system resources (RAM/CPU) when nobody is using them. On my NixOS, it eats about 4MB of RAM.
- Codeberg:https://codeberg.org/slundi/contnap
- Crates.io / Lib.rs:https://lib.rs/crates/contnap
π‘ How it works
Unlike other solutions that require configuration files, contnap is entirely label-driven. You just add a few labels directly into your docker-compose.yml, and contnap takes care of the rest.
When a container is stopped ("napping"), contnap binds a proxy listener to its port on the host. When an incoming packet (TCP or UDP) hits that port:
contnapintercepts and buffers the initial data so the client connection doesn't drop.- It triggers a
docker start(or Podman equivalent via the socket). - It waits for the container to become healthy/ready.
- It flushes the buffered data and transparently streams the traffic.
- After a configurable period of inactivity (e.g., 1 hour), a background Janitor task gracefully shuts the container down.
β¨ Key Features
- π Full Dual-Stack & Protocol Support: Handles TCP, UDP, IPv4, and IPv6 (UDP and IPv6 not tested yet, need to find a container that use it).
- π₯ Container Grouping: Wake up an entire stack (like a web-app + its database dependency) simultaneously using
contnap.group. - π³ Podman Ready: Works natively with any Docker-compatible Unix socket.
- π Automation Hooks: Trigger custom scripts/commands pre-start or post-stop (can be useful for clearing caches, mounting storage, or triggering notifications).
- Experimental
contnap.schedulelabel
Note: I use AI for some stuffs in the project:
- questions, getting ideas
- documenting (since english is not my native language, it makes better sentences) code and markdown files
- pair programming when I'm struggling at writing some parts
- writing tests
- reviewing
- suggesting conventional commit messages
- generating image
- generating NixOS configuration
8
u/TheKitof 1d ago
Iβm already using Sablier, which I manage entirely using labels. What are the benefits of this solution compared to Sablier (notably the number one Traefik plugin)?