Skip to content

Idle-sleep

Why?

Docker containers / Proxmox LXCs consume resources even when they are idle. This can lead to unexpected costs and performance issues.

How?

GoDoxy will put containers to sleep when there is no traffic for a specified period of time. When any traffic is received, the container will be woken up.

Configuration

LabelDescriptionExampleDefaultAccepted values
idle_timeoutinactivity timeout before put it into sleep
❌TCP/UDP
1h30sempty (disabled)number[unit]...
wake_timeouttime to wait for target site to be ready30snumber[unit]...
stop_methodmethod to stop after idle_timeoutstopstop, pause, kill
stop_timeouttime to wait for stop command10snumber[unit]...
stop_signalsignal sent to container for stop and kill methodsdocker's defaultSIGINT, SIGTERM, SIGHUP, SIGQUIT and those without SIG prefix
start_endpointallow waking only from specific endpoint/startempty (allow any)relative URI

Docker

To enable idlesleep, add the following label(s) to your container:

yaml
# compose.yml
services:
  app:
    image: abcd
    ...
    labels:
      proxy.idle_timeout: 1h30s     # required
      proxy.wake_timeout: 30s       # optional
      proxy.stop_method: stop       # optional
      proxy.stop_timeout: 10s       # optional
      proxy.stop_signal: SIGINT     # optional
      proxy.start_endpoint: /start  # optional

Proxmox LXCs

To setup GoDoxy to manage proxmox LXCs. You need to do the following:

  1. Add proxmox credentials to config.yml
yaml
# config.yml
providers:
  proxmox:
    - url: https://pve.domain.com:8006/api2/json
      token_id: root@pam!abcdef
      secret: aaaa-bbbb-cccc-dddd
      no_tls_verify: true
  1. Create API Token on Proxmox

Proxmox API Token

  1. Allow required permissions

Proxmox Permissions

  1. Add LXCs to route files

Node Name:

Proxmox Node Name

VMID:

Proxmox LXC VMID

yaml
lxc-test:
  port: 3000
  idlewatcher:
    idle_timeout: 15s
    proxmox:
      node: pve
      vmid: 119

Released under the MIT License.