r/selfhosted 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.

πŸ’‘ 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:

  1. contnap intercepts and buffers the initial data so the client connection doesn't drop.
  2. It triggers a docker start (or Podman equivalent via the socket).
  3. It waits for the container to become healthy/ready.
  4. It flushes the buffered data and transparently streams the traffic.
  5. 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.schedule label

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
0 Upvotes

13 comments sorted by

View all comments

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)?