Lazytainer

Monitor network traffic to automatically stop and start Docker containers. Save resources by only running services when they are actively being used.

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:

  • Group Management: Assign one or more containers to a group that can be started and stopped together.
  • Label-Based Configuration: All settings are managed via Docker labels, keeping your configuration clean and centralized.
  • Customizable Triggers: Define the inactiveTimeout and minPacketThreshold to fine-tune when containers are considered idle.
  • Flexible Sleep Modes: Choose whether to completely stop a container or simply pause it to save resources.
  • Targeted Monitoring: Specify which network ports and interfaces to monitor for each group of containers.

Directory Structure

lazytainer
.env
docker-compose.yml

docker-compose.yml

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

.env

# No sensitive credentials required for Lazytainer
# Configuration is handled via environment variables directly in the docker-compose.yml

Share:

Ad
Favicon

 

  
 

Similar to Lazytainer

Favicon

 

  
  
Favicon

 

  
  
Favicon