Skip to content

Targets and name resolution

Most commands take a target. You rarely need to say which host runs a service: moira asks every host and picks the match.

Form Example Meaning
host/stack/service edge/shop/shop-prod Fully qualified
host/name nas/shop-prod A container name, service name or stack on that host
host/stack/ edge/shop/ The whole stack, even when a container or service has the same name
name shop-prod Searched on every host: container name, then service name, then stack name
  1. moira fetches the container list from every server, unmanaged containers included.

  2. It collects matches, trying the container name first, then the Compose service name, then the stack name.

  3. For actions, service matches are grouped by host and stack. A pin narrows the matches to its host when that host has one.

  4. One match left: use it.

  5. Several left: if exactly one is running, use it and print which one:

    → edge/shop/shop-prod

    Otherwise fail and list the candidates:

    shop-prod matches 2 services:
    edge/shop/shop-prod running
    nas/shop/shop-prod exited
    use edge/shop-prod, or: moira pin shop-prod edge

Actions never choose between two running copies, not even with --yes. Use a pin or a host prefix.

update, apply and stop ask for confirmation when the target was chosen by the “single running copy” rule, because an exited copy elsewhere was skipped.

An unpinned bare name needs every host to answer before an action can run, because the silent host might hold another running copy. A pinned bare name can use its pinned host while others are down. If nothing matches and any host was unreachable, resolution fails with exit code 3.

A pin says which host a bare name means:

Terminal window
moira pin shop-prod edge
moira unpin shop-prod

Pins live in the client config and are not synced between machines.

Terminal window
moira status edge/shop/ # every service in the stack
moira restart edge/shop/ # asks for confirmation

host/name also resolves a stack by name when no container or service matches, including a stack with no containers yet.

  • Service selectors group scaled replicas by Compose service. Selecting a replica by its container name for an action affects all replicas of that service, and moira asks for confirmation.
  • One-off containers (docker compose run) are excluded from service and stack selectors. Use the exact container name, or host/<container-name>, to see their logs or status. They have no action target.

Hide rows you don’t want in moira ls and the board, such as finished migrations or appliance apps:

Terminal window
moira hide nas/shop-migrate
moira show nas/shop-migrate
moira ls --all # include hidden rows

Hidden entries are stored as exact host/container selectors in the client config.