Self-hosted service
vmorganp/Lazytainer avatar
vmorganp/Lazytainer

Lazytainer watches only the traffic that passes through its own namespace

Docker container lazy loading

777 stars29 forksGoMIT

At a glance

What is it?
A Go daemon that stops or pauses Docker containers when their declared ports go quiet, which only works if each container is labelled and routed through the Lazytainer container's network, and which the shipped demo runs from a floating master tag rather than a release.
Who is it for?
Lazytainer does one narrow thing well: it stops or freezes containers whose declared ports have gone quiet, provided their traffic is routed through its network namespace and they carry the group label. Before adopting it, check that everything you want to sleep can live inside that namespace, pin an image tag instead of tracking master, and read what a read-only Docker socket mount still permits, because the mount flag does not limit the API behind it.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 12 days ago.
What is it written in?
Mainly Go, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • vmorganp/Lazytainer777 ★ · +16
Star history
Repository2026-09-112026-11-25
vmorganp/Lazytainer761777

16 Stars in the last 75 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

The demo pulls a floating tag, and the last release is from March 2025

The compose file at the root of the repository pulls ghcr.io/vmorganp/lazytainer:master, a branch name rather than a version. The tagged releases stop well before the commits do: v2.0.30 is dated 2025-03-19, v2.0.29 sits in February 2025 and v2.0.28 in September 2024, while the last commit on master is dated 2026-07-29. So the artifact the quick start runs is roughly sixteen months of work ahead of the newest tag, and nothing in the instructions pins it. The same file carries the recipe for building locally instead, with a comment telling you to comment out the image line, uncomment build, and run DOCKER_BUILDKIT=1 docker-compose up --build. Release notes on the tags are bare, one line repeating the version number with no description of what changed.

A container must share Lazytainer's network to be watchable

The page states the constraint up front: Lazytainer does not automatically start and stop all of your containers, and each one has to be labelled and have its traffic proxied through the Lazytainer container. The shipped demo shows how, with the sleeping services using network_mode: service:lazytainer, or container:lazytainer when Lazytainer is not in the same compose file, and with their own ports lines commented out and the note that a port should not be configured on that container because traffic is routed through Lazytainer. The container also carries a label naming its group. Together those two requirements define the blast radius: a container on its own bridge network is invisible to the daemon no matter how it is labelled, because the packets never cross the interface being watched, which by default is eth0.

The shipped defaults poll and time out on the same 30 second clock

Seven group properties can be set, and only one is required. ports is the internal port the group watches, comma separated, and the table is explicit that it is not the exposed port, with the worked example that a service running on 8080 but exposed on 80 should be configured as 8080. Those ports must also be forwarded on the Lazytainer container itself. The rest have defaults: inactiveTimeout 30 seconds, pollRate 30 seconds, minPacketThreshold 30 packets, ignoreActiveClients false, sleepMethod stop and netInterface eth0. The demo then overrides the first two down to 10 seconds and 1 second, which means the seven step walkthrough is testing a configuration thirty times more aggressive than the one a new user would otherwise get, and the step that says to wait for the log line stopped container resolves in seconds there rather than after the shipped half minute of quiet.

Sharing a port makes wake-up asymmetric

Two groups can claim the same port, and the compose file's own comment says so, annotating the 81:81 mapping as used by group1 and group2 while 82:82 serves group2 alone. The consequence is spelled out in a second comment on the labels: that configuration will cause traffic to whoami1 to start whoami2, but traffic to only whoami2 will not wake whoami1. In other words the group that claims more ports wakes on more stimuli, and the narrower group is the one that stays asleep when a wider peer is the only thing being touched. That coupling is a property of the port matching rather than of the containers themselves, so two services that share an entry point cannot be woken independently unless each is given a port the other does not claim.

By default a connected client counts as activity even if it sends nothing

The wake condition has two halves and the ignoreActiveClients switch decides whether both are required. With the default of false, activity means the packet count exceeds minPacketThreshold or the connected client count is above zero, so a client that opens a connection and then goes quiet still holds the container awake. Setting it to true removes the second half and leaves packets alone as the only evidence of life. The threshold itself defaults to 30 packets, which is a count rather than a rate: it says nothing about how much data moved, only that enough discrete packets arrived between polls. The table offers no setting for how long a connection has to be idle before it stops counting, so the client-side behaviour is not something the group configuration can express.

The runtime stage installs the libpcap build package

The Dockerfile is a two stage build. The first stage starts from golang:1.23-alpine3.19, installs build-base, gcc, wget, git and libpcap-dev, copies src into /app, and then runs go mod tidy as part of the same build layer as the compile, with CGO_ENABLED=1 and flags for trimming paths and stripping symbols. The second stage starts from plain alpine and installs libpcap-dev again, then copies the single binary across and sets a relative entrypoint of ./app/lazytainer. Two things follow. The runtime image carries the development package for the packet capture library rather than the runtime library, which is the toolchain half of a dependency the binary links dynamically. And because go mod tidy runs during the image build, the dependency graph is resolved when the image is built rather than being fixed by what is committed, so two builds of the same source can differ.

A read-only socket mount still exposes the whole engine API

One volume is marked as mandatory:

yaml
lazytainer:
  # ... configuration omitted for brevity
  volumes:
    - /var/run/docker.sock:/var/run/docker.sock:ro

The ro flag applies to the mount, not to the API reachable through it, so anything holding that socket can still issue the write calls the daemon permits, and the daemon here needs exactly those calls, since starting and stopping other containers is the product. Membership is decided by label rather than by any separate permission, so a container labelled lazytainer.group= becomes eligible for control as soon as it shares the namespace. The shipped compose file also leaves VERBOSE=true switched on, with a comment suggesting it be set to false unless you are debugging or doing the initial demo, and exposes IPV4_DISABLED and IPV6_DISABLED as environment toggles for narrowing which families the listener binds.

Two spellings of the compose command in one page

The walkthrough mixes the two command names. Step two is docker compose up, with a comment saying that if docker compose does not work, try docker-compose. Step seven, the cleanup, is docker-compose down. The build recipe in the compose file is DOCKER_BUILDKIT=1 docker-compose up --build, the hyphenated form again. The file itself is named docker-compose.yaml and still opens with a version key set to 3, which current Compose ignores. The test procedure underneath is otherwise honest about what to expect: navigate to http://localhost:81, close the tab, wait until the logs say stopped container, navigate again and get a dead page, then generate traffic on port 81 several times and watch it start. Three example setups ship alongside, for a Minecraft server, a Satisfactory server and ZeroTier.

Editorial conclusion

Lazytainer does one narrow thing well: it stops or freezes containers whose declared ports have gone quiet, provided their traffic is routed through its network namespace and they carry the group label. Before adopting it, check that everything you want to sleep can live inside that namespace, pin an image tag instead of tracking master, and read what a read-only Docker socket mount still permits, because the mount flag does not limit the API behind it.

Frequently asked questions

How does Lazytainer decide a container should wake up?

By network traffic reaching the ports its group claims. The group needs a ports label on the Lazytainer container, the sleeping container needs a lazytainer.group label, and its traffic has to be routed through the Lazytainer container. The shipped defaults are a 30 second inactivity timeout, a 30 second poll rate and a 30 packet threshold.

Does Lazytainer stop or pause containers?

Either one, through the sleepMethod group property: stop by default, or pause to freeze the process where it stands. The shipped demo uses pause for one group and stop for the other, and leaving the property blank also means stop.

What does Lazytainer need from the Docker host?

A bind mount of the Docker socket at /var/run/docker.sock, which the page marks as mandatory, mounted read-only. That flag applies to the mount rather than to the API behind the socket, and the daemon needs write access in order to start and stop other containers.

Which version of Lazytainer does the compose file run?

The floating tag ghcr.io/vmorganp/lazytainer:master, not a versioned tag. The newest GitHub release is v2.0.30 from 2025-03-19, while the last commit on master is dated 2026-07-29.

What examples ship with Lazytainer?

Three setups under examples/: minecraft, satisfactory and zerotier. The first two are game servers, the case where stopping the container cleanly rather than losing the process is the point.

Official sources

  1. Issues
  2. License: MIT
  3. README
  4. Releases
  5. vmorganp/Lazytainer on GitHub
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/vmorganp-lazytainer.svg)](https://hysenlabs.com/projects/vmorganp-lazytainer)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/vmorganp-lazytainer.svg)](https://hysenlabs.com/projects/vmorganp-lazytainer)

Was this useful?