Skip to main content
A secret set is a named bundle of environment variables, like an app’s .env file.
  • A Private set delivers values to a host. The web app shows variable names, and the daemon holds the values in memory for local processes.
  • A Team-visible set lets people with access select Reveal values in the web app. It cannot be bound to a host.
Unbind every host before changing a private set to team-visible.

Create a set

  1. Open Secret sets and select New set.
  2. Give the set a name. Leave Visible to the team off to deliver values to a host.
  3. Add variables or paste the contents of an .env file into a variable field, then select Create set.
Creating a set requires the global set.add permission. Open the set later to add or update variables.

Bind it to a host

  1. Open the private set and select Bind hosts under Bound hosts.
  2. Choose one or more hosts. To restrict which Unix account can use the set, fill in Run as user (optional).
  3. Confirm the binding. Custos delivers the set to connected hosts immediately and to offline hosts when they reconnect.
Binding and unbinding require set.manage on the set and host.access on the host. To remove a binding, use the unbind action beside the host in Bound hosts. For automation, see Create a set, Bind a set to a host, and Unbind a set from a host.

Launch the app

The important pattern is always:
custosd exec fetches the bound machine-secret set from the local daemon, injects those values into the child process environment, then replaces itself with APP_RUN_CMD.

Socket access

Run custosd exec as a user that belongs to the custos Unix group. This applies to interactive shell users and to service users used by systemd, PM2, Docker, or other process managers:
Group changes take effect in a new login session. Log out and back in before testing an interactive user; restart a service after changing its service user’s groups. The daemon creates /run/custos/secrets.sock with mode 0660 and ownership custos:custos. 0660 means the owning user and group may read from and write to the socket (6 = 4 read + 2 write), while all other users have no access (0). Root can bypass this filesystem restriction. An as_user binding is an additional restriction checked after the caller connects. Omitting as_user allows any caller with access to the socket; it does not grant socket access to users outside the custos group. To check which sets a user can consume, run sudo -u APP_USER custosd set-list (add --json for a JSON array). See set-list.

Docker

Use this when the app runs in a container, but custosd runs on the host.
custosd exec injects the set into the docker run process. Docker then copies each named variable from the Docker client’s environment into the container because the flags are passed as -e NAME instead of -e NAME=value. Writing one -e NAME per variable does the same thing, but a set with a hundred variables needs a hundred flags. {{custos.expand:TEMPLATE}} is a placeholder that custosd exec replaces, before starting the command, with TEMPLATE repeated once per name in the set, sorted. The example above expands to docker run --rm -e TEST_1 -e TEST_2 -e TEST_3 IMAGE_NAME. Only names are expanded, never values, so secrets stay out of the command line where ps would show them.

Expansion templates

A template is split on spaces into arguments. Write {} where the name belongs; if the template has no {}, the name is added as a final argument. That covers the shapes command line tools use: So the same placeholder works for anything that reads a named variable from the environment of the command that starts it, such as a Docker build:
A space in a template separates one argument from the next, so no single argument can contain a space. There is no quoting or escaping inside a template to work around this. Quote the whole placeholder whenever the template contains a space, as in the --pass env {} row above:
Without the quotes the shell splits the placeholder into separate arguments before custosd reads it, and the command fails. Quotes are also what let a template contain a comma. A single-word template such as {{custos.expand:-e}} needs no quotes. A command with no placeholder runs exactly as before. If the binding uses as_user, run the command as that exact Unix user.

PM2

Use this when PM2 starts the app process directly on the host.
The environment values are injected into the pm2 command. PM2 then records that environment for the started process. If a process is already running, restart it through custosd exec so PM2 receives the fresh values:
If the binding uses as_user, run the command as that exact Unix user.

systemd

Use this when systemd owns the app lifecycle.
As described under Socket access, add the service user to the custos group and restart the service after its group membership is active:
If the binding uses as_user, set User= to that exact Unix user.