selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

GitHub
ContainerNursery logo

Self-host ContainerNursery

1.9.0

Reverse proxy that sleeps and wakes Docker containers

ReleaseOpen SourceMIT
Updated2 years ago
LanguageTypescript
Setup difficultyModerate
Stars
256
Port
80 (HTTP reverse proxy)
Docker
ghcr.io/itsecholot/containernursery
Install with Docker
ContainerNursery screenshot 1ContainerNursery screenshot 2

What is ContainerNursery?

ContainerNursery is a self-hosted reverse proxy written in Node.js that puts Docker containers to sleep when idle and wakes them when new HTTP requests arrive. It connects to the Docker daemon via /var/run/docker.sock. Key capabilities include automatic container start/stop based on configurable timeout, WebSocket-aware stopping, a loading page that auto-reloads when the target is ready, support for multiple domains and containers per host, HTTPS proxying to containers, CPU-aware stopping prevention, and customizable ready-check HTTP methods. Configuration uses a config.yml file with live reload, plus environment variables for logging and port. The project recommends running behind another reverse proxy for HTTPS. It is distributed as a Docker image on ghcr.io.

Should you self-host ContainerNursery?

ContainerNursery scores 47/100 on selfhost.directory (how scoring works) and ranks #4 of 5 in Docker Management. It has 256 GitHub stars.

There was no stable release in the past 12 months, so check the repository's recent activity before you rely on it.

Setup is moderate: expect some configuration beyond a single command. An official Docker image is available. It is MIT-licensed and written mostly in Typescript.

Its closest alternative on selfhost.directory is dockge (76/100, 24 700 stars). It scores higher overall, so compare the two before you pick. See ContainerNursery vs dockge side by side.

Features

  • Automatic container start/stop
  • CPU-aware stopping prevention
  • Customizable ready-check HTTP method
  • HTTPS proxying to containers
  • Live configuration reload
  • Loading page with auto-reload
  • Multiple containers per host
  • Multiple domains per proxy host
  • WebSocket-aware stopping

ContainerNursery README

How to install ContainerNursery

Install ContainerNursery with Docker

Docker daemon with accessible /var/run/docker.sock
Environment variables
CN_LOG_JSON, CN_LOG_LEVEL, CN_PORT

docker pull ghcr.io/itsecholot/containernursery:latest

docker run
--name='ContainerNursery'
-v /var/run/docker.sock:/var/run/docker.sock
-v /mnt/ContainerNursery/config:/usr/src/app/config
ghcr.io/itsecholot/containernursery:latest

Requires mounting Docker socket and config volume

How to configure ContainerNursery

  • CN_LOG_JSONfalseIf set to true all logging is done in a machine readable format (JSON)

    If set to true all logging is done in a machine readable format (JSON)

    values: true / false

  • CN_LOG_LEVELinfoSets the minimum log level. Log entries below this importance level won't be printed to the console

    Sets the minimum log level. Log entries below this importance level won't be printed to the console

    values: debug / info / warn / error

  • CN_PORT80Sets the port ContainerNursery listens on for new http connections. The proxyListeningPort option in the config.yml file takes precedence if both are set

    Sets the port ContainerNursery listens on for new http connections. The proxyListeningPort option in the config.yml file takes precedence if both are set

    values: integer

  • containerNameArray or string of which container(s) (by name or id) to start and stop. ContainerNursery can start and stop multiple containers for a single proxy host

    Array or string of which container(s) (by name or id) to start and stop. ContainerNursery can start and stop multiple containers for a single proxy host

    values: array or string

  • displayNameThe name (of the service) that should be displayed on the waiting page

    The name (of the service) that should be displayed on the waiting page

    values: string

  • domainArray or string containing domain(s) to listen for (equals the host header)

    Array or string containing domain(s) to listen for (equals the host header)

    values: array or string

  • proxyHostDomain / IP of container (use custom Docker bridge networks for dynDNS using the name of the container)

    Domain / IP of container (use custom Docker bridge networks for dynDNS using the name of the container)

    values: string

  • proxyListeningPort80The port ContainerNursery should listen on for new http connections

    The port ContainerNursery should listen on for new http connections

    values: integer

  • proxyPortPort on which the containers webserver listens on

    Port on which the containers webserver listens on

    values: integer

  • proxyUseCustomMethodCan be set to a HTTP method (HEAD, GET, ...) which should be used for the ready check

    Can be set to a HTTP method (HEAD, GET, ...) which should be used for the ready check

    values: HTTP method string

  • proxyUseHttpsfalseBoolean indicating if the proxy should use HTTPS to connect to the container. Defaults to false. This should only be used if the container only accepts HTTPS requests

    Boolean indicating if the proxy should use HTTPS to connect to the container. Defaults to false. This should only be used if the container only accepts HTTPS requests

    values: true / false

  • stopOnTimeoutIfCpuUsageBelowIf set, prevents the container from stopping when reaching the configured timeout if the averaged CPU usage of the main container is above this value

    If set, prevents the container from stopping when reaching the configured timeout if the averaged CPU usage of the main container is above this value

    values: integer (percentage 0-100*core count)

  • timeoutSecondsSeconds after which the container should be stopped. The internal timeout gets reset to this configured value every time a new HTTP request is made, or when the timer runs out while a Websocket connection is still active

    Seconds after which the container should be stopped. The internal timeout gets reset to this configured value every time a new HTTP request is made, or when the timer runs out while a Websocket connection is still active

    values: integer

More in Docker Management

Rate this project

Click to rate — no account needed.

0 comments

Posting as guest
Loading comments…