Service, proxy, and builder configuration
Service configuration defines the supporting services and shared tools that make an application deployable. It connects accessories to hosts, sends images through a registry, selects a build strategy, routes traffic through the proxy, and controls both container and deploy-log output.
Configuration relationships
The configuration has two paths. The builder creates an image for the registry. Application and accessory settings then use that image or their own image, while the proxy exposes selected services and logging records the work.
The parent page, Deployment configuration system, explains how the full configuration is loaded and merged. Application topology configuration explains the hosts and roles that these settings target. Environment and secrets resolution explains how secret names and environment values become usable by services.
This diagram shows the main relationships between the service settings.
flowchart LR
B[Builder] --> I[Application image]
I --> R[Registry]
R --> A[Application containers]
X[Accessory settings] --> R
X --> S[Accessory containers]
A --> P[Proxy]
S --> P
L[Docker logging] --> A
L --> S
O[Deploy output] --> D[File or OpenTelemetry endpoint]
Configuration validation
Each service block is checked against its documented shape before commands use it. Unknown keys and wrong value types fail early. Service-specific checks then protect host selection, network exposure, credentials, build choices, and required output settings.
The validator permits x- extension keys for shared YAML fragments at the root level. It does not make unknown keys valid inside the service blocks described here. This keeps a misspelled setting from silently changing deployment behavior.
References: lib/…/validation.rb• L17-26 lib/…/validator.rb• L15-31 lib/…/configuration.rb• L1-5
Accessory services
An accessory is a separately managed container for a supporting service such as a database or cache. It has its own image, host placement, environment, mounts, network, ports, and optional proxy or registry settings. Accessories are not part of the application deploy rollout and do not receive zero-downtime updates.
Accessory placement and runtime
An accessory must select exactly one placement form: a host list or a server role or tag. Its role references must name existing roles. The default service name is based on the application service and accessory name, and the default network is kamal.
Accessories can mount copied files, created directories, and existing Docker volumes. They can also set a command and Docker options. A custom restart option must use no, always, unless-stopped, or on-failure with an optional retry count.
References: lib/…/accessory.rb• L12-27 lib/…/accessory.rb• L29-35 lib/…/accessory.rb• L77-111 lib/…/accessory.rb• L317-323 lib/…/accessory.yml• L1-9
Accessory exposure
An accessory port must name its bind address. This makes private and public exposure explicit instead of allowing a default that may expose a backing service. The same rule applies to a publish option passed through Docker options.
Accessory labels cannot replace the reserved destination, role, or service labels. A port without a valid IPv4 or IPv6 bind address fails before an existing container is rebound.
References: lib/…/accessory.rb• L280-315 lib/…/validator.rb• L222-249 lib/…/accessory.yml• L67-81
Proxy routing
The proxy is the traffic boundary for proxied application roles and accessories. It forwards requests to a service port and can provide host matching, HTTPS, health checks, path routing, buffering, timeouts, and request or response header logs.
Application and accessory proxy settings
Proxy settings belong to the service being routed. A root proxy setting is combined with a role-specific setting, while an accessory can carry its own proxy block. The primary role uses the proxy by default. Other roles need an explicit proxy setting, and a role can disable the proxy with proxy: false.
Host matching can use host or hosts, but not both. With no host match, the proxy can forward general requests that are not claimed by another application. SSL can use automatic certificate management or a custom certificate and key read from secrets.
References: lib/…/proxy.rb• L9-18 lib/…/proxy.rb• L20-95 lib/…/role.rb• L66-80 lib/…/role.rb• L167-187 lib/…/proxy.yml• L15-81
Proxy run settings
The run block controls the shared proxy container rather than one application's route. It selects the published HTTP and HTTPS ports, bind addresses, metrics port, image source and version, log size, debug mode, and extra Docker options. Publishing is enabled by default and uses ports 80 and 443 unless changed.
Automatic SSL requires a host. A custom SSL setting must provide both the certificate secret and the private-key secret. A role using automatic SSL must have one host; multiple hosts require custom certificates. When publishing is disabled, the HTTP port, HTTPS port, and bind-address settings cannot also be set.
References: lib/…/run.rb• L1-5 lib/…/run.rb• L16-70 lib/…/proxy.rb• L3-35 lib/…/role.rb• L160-163 lib/…/proxy.yml• L151-173
Registry access
The registry is the image exchange point between building and running containers. Docker Hub is the default. A configured server changes where application, accessory, or proxy images are pushed and pulled.
Credentials may be literal strings or one-item arrays that name secrets. A non-local registry needs both a username and a password. A server whose name starts with localhost is treated as a local registry and does not need credentials; its port also identifies the local registry endpoint.
References: lib/…/registry.rb• L1-28 lib/…/registry.rb• L1-25 lib/…/registry.yml• L1-24
Image builder
The builder turns application source into an image suitable for the configured deployment architecture. It can use local or remote build capacity, build one or more architectures, use buildpacks, reuse build cache, and add build arguments or secrets.
Build targets and sources
The builder chooses the build context, Dockerfile, target, driver, and optional Pack buildpack builder. Without a context, Kamal can build from a clean Git clone. A remote builder handles architectures that do not match the local host, while local: false sends all work to the remote builder.
The builder can also add SSH access, provenance data, and an SBOM setting to the image build. These settings affect the image supply chain rather than the service runtime.
References: lib/…/builder.rb• L22-58 lib/…/builder.rb• L64-101 lib/…/builder.rb• L126-153 lib/…/builder.yml• L12-45 lib/…/builder.yml• L57-132
Build cache
Build cache can use GitHub Actions or a registry. Registry cache uses the configured registry and defaults to an image name derived from the application image. Cache options control the cache exporter and importer without changing the final application image.
The cache type must be gha or registry. The builder requires an architecture setting. Buildpacks support one architecture only. Local builds cannot be disabled unless a remote builder is configured.
References: lib/…/builder.rb• L104-123 lib/…/builder.rb• L172-201 lib/…/builder.rb• L1-14 lib/…/builder.yml• L47-55
Docker logging
Docker logging controls how container output is stored or shipped on the host. The setting can apply to every application container at the root level and can be merged with a different setting for a role.
If no driver or option is set, containers use a default max-size option of 10m. Setting a driver or any options replaces that default with the requested Docker logging configuration. This is separate from deploy output, which records Kamal command activity.
References: lib/…/logging.rb• L6-31 lib/…/role.rb• L23-25 lib/…/role.rb• L62-68 lib/…/logging.yml• L1-21
Deploy output
Deploy output sends Kamal command logs to one or more external destinations. It is disabled when the output block is empty or absent. It can write one log file per command, ship records to an OpenTelemetry-compatible endpoint, or do both at the same time.
OpenTelemetry output requires an endpoint. File output requires a path. The output configuration accepts the supported otel and file logger types and creates one logger for each configured type. Each logger receives command activity and records success or failure at command completion.
References: lib/…/output.rb• L1-33 lib/…/otel_logger.rb• L1-9 lib/…/file_logger.rb• L1-7 lib/…/base_logger.rb• L3-29 lib/…/output.yml• L1-25
Change checklist
When these files or sections are changed, remember to consider these:
- When changing registry server or credentials, check application images, accessory images, proxy run images, and registry cache references together.
- When changing proxy
runpublishing, check host firewall rules and any application or accessory port assumptions. - When changing role proxy settings, check automatic SSL host count and the shared root proxy merge.
- When changing builder architectures or local and remote settings, check the deployment hosts and the selected builder driver.
- When changing logging or output destinations, keep container logs separate from deploy-command logs so operators know where to look.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| An accessory declares more than one placement selector or an unknown role | Accessory configuration is rejected | Use one of host, hosts, role, roles, tag, or tags and name existing roles |
| An accessory publishes a port without a bind address | Configuration fails instead of making exposure implicit | Use a full mapping such as 127.0.0.1:PORT:PORT or 0.0.0.0:PORT:PORT |
| SSL has no host or only one custom certificate part | Proxy validation fails before routing starts | Set a host for automatic SSL and provide both certificate and key for custom SSL |
| A remote registry lacks credentials or a builder uses an invalid cache type | Image transfer or configuration fails | Provide both registry credentials and use gha or registry cache |
| Local builds are disabled without a remote builder | No valid build target remains | Set a remote builder when local: false |
| Output logger settings omit their required destination | Output setup fails | Set otel.endpoint or file.path |
Key files
| File | Why to read it |
|---|---|
| lib/…/accessory.rb | Shows the service-level model for accessory placement, mounts, ports, and optional integrations. |
| lib/…/proxy.rb | Shows the application-specific proxy features that become route settings. |
| lib/…/run.rb | Shows the shared proxy container settings and image selection. |
| lib/…/registry.rb | Shows registry identity, credential lookup, and local-registry detection. |
| lib/…/builder.rb | Shows how architecture, builder location, cache, and build inputs shape image creation. |
| lib/…/logging.rb | Shows the Docker logging default and merge behavior. |
| lib/…/output.rb | Shows how deploy output settings become file or OpenTelemetry loggers. |
| lib/…/validator.rb | Shows shared type, unknown-key, label, Docker option, and path checks. |
| lib/…/proxy.rb | Shows proxy host, SSL, publishing, and bind-address constraints. |
| lib/…/builder.rb | Shows builder cache, architecture, Pack, and local-build constraints. |