Docker runtime and node images
Polar uses Docker as the runtime for local Bitcoin, Lightning, Taproot Assets, and simulation networks. It checks that Docker and Docker Compose are available, turns each network into a Compose environment, selects the images and startup commands for each node, and gives the user direct access to container logs and shells.
Runtime boundary
Docker availability
Polar treats Docker and Docker Compose as one runtime boundary. At startup it discovers the Docker engine through the configured Docker environment or common local socket paths, then records the Docker and Compose versions for the app state and status display. If either tool is not available, the app shows a setup prompt with platform-specific install links and a retry action. src/…/dockerService.ts• L37-105 src/…/DetectDockerModal.tsx• L45-103
References: src/…/dockerService.ts• L37-105 src/…/DetectDockerModal.tsx• L45-103 src/…/DockerStatus.tsx• L20-30
Network container lifecycle
The network state model owns the user action while the Docker service performs the runtime action. Before a network starts, Polar checks for required non-bundled images and confirms that host ports are usable. It then writes the current Compose file, starts or stops the full environment, refreshes the known image list, and waits for node services to become ready. Individual nodes and simulations use the same boundary with narrower start, stop, and remove actions. src/…/network.ts• L735-803 src/…/dockerService.ts• L183-253
The runtime also keeps local node data aligned with node identity. Renaming a node updates its host data directory and related container data. Windows uses special handling for Core Lightning data because that data lives in a Docker named volume rather than only in a host folder. src/…/dockerService.ts• L256-290 src/…/dockerService.ts• L572-780
References: src/…/network.ts• L735-803 src/…/network.ts• L834-863 src/…/dockerService.ts• L183-253 src/…/dockerService.ts• L256-290 src/…/dockerService.ts• L572-780
Compose-based node environments
Network environment
Each Polar network has a working directory and a generated docker-compose.yml. The file describes one service for each Bitcoin, Lightning, Taproot Assets, or simulation node. Compose gives those services stable names, shared network-level discovery, persistent data mounts, exposed node ports, and restart behavior. This lets Polar manage a complete local network as one unit while still addressing a single node when needed. src/…/dockerService.ts• L130-180 src/…/composeFile.ts• L43-63
The generation flow connects services according to the network model. Lightning nodes point to a Bitcoin backend. Taproot Assets nodes point to an LND backend. Litd nodes also share their proof courier relationship. A simulation adds one more service that reads the generated activity description and the node credentials mounted into the environment. src/…/dockerService.ts• L136-175 src/…/dockerService.ts• L221-225
This diagram shows how a saved network becomes a running Docker environment.
flowchart LR
A[Network state] --> B[Compose environment]
B --> C[Node images and commands]
B --> D[Persistent node data]
B --> E[Host ports and service names]
C --> F[Docker Compose]
D --> F
E --> F
F --> G[Running network]
References: src/…/dockerService.ts• L130-180 src/…/composeFile.ts• L43-63 src/…/composeFile.ts• L65-225 src/…/network.ts• L303-358
Node service configuration
Polar keeps a common runtime shape for each supported node type, then fills it with the image, version, ports, persistent paths, and startup command that belong to that node. Commands can contain named variables for node names, service names, backend links, and shared credentials. Polar resolves those values when it creates the Compose service so nodes can find each other inside the network. src/…/composeFile.ts• L65-219
The default image and command come from the selected node version. A node can instead carry a custom image and command. Older supported versions can receive adjusted default flags when a newer option is not valid for that version. The Bundled node containers page covers the container definitions and entrypoints that provide these runtime images.
References: src/…/composeFile.ts• L65-219 src/…/constants.ts• L100-349 src/…/network.ts• L717-739 src/…/index.ts• L96-107
Persistent node data
Node state is stored below the network directory and mounted into the matching container service. Polar creates these directories before Docker starts so the host user owns new files on Linux. The same model supports node-specific data such as Bitcoin data, Lightning credentials, Litd state, and Taproot Assets state. src/…/dockerService.ts• L397-416 src/…/config.ts• L26-38
References: src/…/dockerService.ts• L397-416 src/…/nodeTemplates.ts• L8-210 src/…/config.ts• L26-38
Image sources and repository state
Managed image catalog
Polar separates the list of available node versions from the list of images already present in the local Docker engine. The managed catalog is seeded from app defaults and may be updated from a remote repository state file. Each implementation has a latest version, a set of supported versions, and compatibility data where a Lightning version depends on a suitable Bitcoin version. src/…/constants.ts• L352-364 src/…/index.ts• L109-124
At initialization Polar loads a newer saved catalog when one exists, checks the Docker engine for local image tags, and can compare the local catalog with the remote catalog. The update check reports new versions without pulling them. Network startup then lets Compose obtain the managed images that the selected network needs. src/…/app.ts• L128-137 src/…/repoService.ts• L46-103 src/…/dockerService.ts• L109-127
The image update flow is user-controlled. Polar can check at startup when the setting is enabled. When new versions exist, the update view shows the changes and saves the new catalog only after the user accepts them. src/…/app.ts• L134-137 src/…/ImageUpdatesModal.tsx• L42-130
References: src/…/constants.ts• L352-364 src/…/index.ts• L109-124 src/…/app.ts• L106-137 src/…/repoService.ts• L10-103 src/…/ImageUpdatesModal.tsx• L42-130
Custom image definitions
Custom images let an engineer use a locally tagged Docker image with a chosen node implementation and startup command. Polar stores these definitions in settings. When a network is created or a node is added, the selected custom definition becomes part of that node rather than changing the managed catalog. src/…/index.ts• L49-59 src/…/app.ts• L184-207 src/…/network.ts• L360-455
The node image screen shows custom images beside the managed catalog. It refreshes local Docker image tags before a custom image is saved, offers platform-supported node types, and allows custom definitions to be edited or removed. See Node image management for the user-facing image workflow.
References: src/…/NodeImagesView.tsx• L25-63 src/…/CustomImageModal.tsx• L18-131 src/…/CustomImagesTable.tsx• L44-141 src/…/DockerImageInput.tsx• L13-45
Image readiness
Before a network starts, Polar derives the image tag required by every node. It uses the node's custom tag when present and otherwise builds the tag from the managed repository and node version. It removes duplicates and compares the result with the tags reported by Docker. Missing custom images stop the start action with a clear error rather than allowing Compose to fail later. src/…/network.ts• L693-714 src/…/network.ts• L741-750
References: src/…/network.ts• L693-714 src/…/network.ts• L741-750 src/…/dockerService.ts• L109-127
Container observation and access
Container logs
Polar presents live Docker output in a separate log window. The log view locates the container by its stable name, reads recent output, follows new output, and merges standard output with standard error into one searchable stream. If the container ends, the view closes the connection and tells the user that Docker terminated it. src/…/ViewLogsButton.tsx• L16-43 src/…/DockerLogs.tsx• L17-59
References: src/…/ViewLogsButton.tsx• L16-43 src/…/DockerLogs.tsx• L25-59 src/…/DockerLogs.tsx• L86-139
Container terminals
The terminal view provides an interactive shell inside a running node container. It maps keyboard input and terminal output to a Docker exec session, selects the node's runtime user, and adds safe network-specific command aliases such as lncli, bitcoin-cli, or tapcli. Terminal size changes follow the window, and the window closes when the container exits. src/…/OpenTerminalButton.tsx• L16-59 src/…/DockerTerminal.tsx• L56-139
Logs and terminals are views over the same container identity used by Compose. This keeps the user-facing node controls, runtime services, and diagnostic tools aligned even when a network contains several nodes of the same implementation. src/…/Routes.tsx• L23-39 src/…/network.ts• L631-690
References: src/…/OpenTerminalButton.tsx• L16-59 src/…/DockerTerminal.tsx• L88-139 src/…/Routes.tsx• L23-39 src/…/network.ts• L631-690
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the node configuration, Compose service builder, and command-variable help aligned when a node image, startup flag, or variable changes.
- Keep image repository metadata and the built image tags aligned when adding or removing a managed node version.
- Preserve the relationship between node names, Compose container names, backend references, mounted data paths, log routes, and terminal routes when naming rules change.
- Recheck Linux directory ownership and Windows Core Lightning volume transfer when changing volume mounts or node data paths.
- Keep the image readiness check aligned with the way custom image tags are selected in network creation and node addition.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Docker or Docker Compose cannot be detected | Polar cannot run the container environment and shows the setup prompt | Retry detection after starting the local Docker service or install the missing tool |
| A required custom image is not present in Docker | Network start stops before Compose runs | Pull or build the exact tag shown in the custom image definition |
| A node command uses a variable that the service builder does not supply | The generated container command can point to the wrong peer or fail at startup | Keep command variables in the node configuration and Compose builder in sync |
| A node container is removed while its log or terminal window is open | The stream ends and the view reports or closes the connection | Start the node before opening its diagnostic view and reopen it after the node restarts |
| A Windows Core Lightning named volume is not copied during a host-data operation | Exported or restored state can omit the node's private data | Use the Docker volume transfer path for Windows Core Lightning nodes |
Key files
| File | Why to read it |
|---|---|
| src/…/dockerService.ts | Defines the Docker boundary for detection, Compose control, network persistence, and image inspection. |
| src/…/composeFile.ts | Shows how network state becomes a Compose service set and how node links and commands are resolved. |
| src/…/nodeTemplates.ts | Shows the shared service shape for each supported node family and its mounted data and ports. |
| src/…/repoService.ts | Explains how the managed image catalog is stored and compared with the remote catalog. |
| src/…/constants.ts | Defines the supported image sources, default commands, platform support, and repository metadata. |
| src/…/network.ts | Connects node image selection with network creation, compatibility, container names, and image readiness. |
| src/…/app.ts | Coordinates Docker versions, local image tags, image settings, and repository state in app state. |
| src/…/network.ts | Connects network and node actions to Compose generation and container lifecycle changes. |
| src/…/DockerLogs.tsx | Explains the live log stream presented for a running container. |
| src/…/DockerTerminal.tsx | Explains the interactive shell presented for a running node container. |
| src/…/NodeImagesView.tsx | Provides the entry point for managed and custom image management. |