Lazytainer is a utility designed to optimize resource usage by managing the lifecycle of your Docker containers. It automatically stops or pauses containers that are not in use and starts them again as soon as network traffic is detected. This is particularly useful for development environments or home labs where numerous services might be running but are only needed intermittently, helping you save significant CPU and RAM.
The tool works by monitoring network traffic directed at your services. You configure which containers to manage by applying a simple Docker label. When a request is made to a service, Lazytainer intercepts it and ensures the corresponding container is running before forwarding the traffic. If a container remains idle for a configurable period, Lazytainer will put it to sleep.
Key features include:
inactiveTimeout and minPacketThreshold to fine-tune when containers are considered idle.stop a container or simply pause it to save resources.services:
lazytainer:
container_name: lazytainer
image: ghcr.io/vmorganp/lazytainer:master
environment:
- PORT=80,81
- LABEL=lazytainer
- TIMEOUT=30
- MINPACKET=0
- VERBOSE=true
ports:
- 80:80
- 81:81
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
whoami:
container_name: whoami
image: containous/whoami
labels:
- "lazytainer=true"
network_mode: service:lazytainer
depends_on:
- lazytainer# No sensitive credentials required for Lazytainer
# Configuration is handled via environment variables directly in the docker-compose.ymlAuto-fetched about 24 hours ago
Auto-fetched about 24 hours ago