Skip to content
COMA

Contexts

A context is a named default target for COMA commands. It is not a Docker context, and coma use does not switch the Docker CLI.

A context is a named default target. It records which machine COMA commands use when you do not pass --machine, and which engine to prefer when that machine has both Docker and Podman.

coma use does not switch docker

coma use dev makes dev the target for coma docker, coma podman and other COMA commands. Your local docker CLI still talks to whatever it talked to before. To point docker, Compose and other tools at the machine, run coma connect.

Choose a machine with coma use

coma use dev

coma use (also coma machine use) sets the machine of the current context. If there is no current context yet, COMA creates one called default and makes it current. The output says so:

Created context default and made it current
Context default now targets machine dev
Run the machine's engine CLI with `coma docker ...` or `coma podman ...`. Your local docker CLI is unchanged.

After that, coma docker ps runs on dev, and coma connect with no argument connects to dev.

Manage contexts

Use several contexts when you switch between machines, for example a personal VM and a team build box.

coma context create work --description "Team build box" --use
coma use buildbox
coma context list
CURRENT  NAME     MACHINE   DESCRIPTION
         default  dev
*        work     buildbox  Team build box
CommandWhat it does
coma context create <name>Create a context; --use also makes it current
coma context use <name>Make a context current
coma context currentShow the current context and where it was chosen
coma context listList contexts; * marks the current one
coma context inspect <name>Show a context's ID, machine and whether it is current
coma context rename <name> <new-name>Rename a context
coma context remove <name>Remove a context; machines it points at are not affected
coma engine use podmanPrefer an engine when the machine has both; auto clears it

Context names follow the same rules as machine names and are unique regardless of case. Context IDs start with ctx_.

Removing the current context asks for confirmation (--yes in scripts). Afterwards there is no current context until you choose one; COMA does not fall back to another.

Which context is current

COMA decides the current context for each command, in this order:

  1. the --context <name> flag, for that command only;
  2. the COMA_CONTEXT environment variable, for that shell;
  3. currentContext in COMA's config file, which coma context use and coma use write.

coma context current shows the result and its source:

work (from file)

The source is flag, env or file. If you run coma context use while COMA_CONTEXT or --context is set, COMA warns that the override still wins in that shell.

COMA contexts and Docker contexts

COMA contexts and Docker contexts are separate things with similar names.

COMA contextDocker context
Used bycoma commandsthe docker CLI and Compose
Created bycoma context create, coma usecoma connect, coma docker-context install
Selected withcoma --context <name>, COMA_CONTEXTdocker --context <name>, DOCKER_CONTEXT
Stored inCOMA's config and stateDocker's own context store

coma connect creates a Docker context named coma that points at a private local socket for the machine, and makes it the Docker CLI's current context. It records the context you used before; coma disconnect switches back to it.

coma connect dev
docker compose up
coma disconnect
  • coma connect --no-switch installs the coma Docker context without making it current. Use it per command with docker --context coma ….
  • coma docker-context install --machine dev --engine docker adds a Docker context fixed to one machine and engine, named coma-dev-docker. It does not switch to it, so you can use several machines side by side.
  • COMA changes only Docker contexts it created. If a Docker context named coma already exists and COMA did not create it, coma connect stops with docker_context_conflict; --replace takes it over.
  • DOCKER_HOST and DOCKER_CONTEXT override the Docker CLI's current context. coma connect warns when either is set.

For tools that ignore Docker contexts, see Tools that ignore Docker contexts.

Next

On this page