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 devcoma 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 listCURRENT NAME MACHINE DESCRIPTION
default dev
* work buildbox Team build box| Command | What it does |
|---|---|
coma context create <name> | Create a context; --use also makes it current |
coma context use <name> | Make a context current |
coma context current | Show the current context and where it was chosen |
coma context list | List 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 podman | Prefer 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:
- the
--context <name>flag, for that command only; - the
COMA_CONTEXTenvironment variable, for that shell; currentContextin COMA's config file, whichcoma context useandcoma usewrite.
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 context | Docker context | |
|---|---|---|
| Used by | coma commands | the docker CLI and Compose |
| Created by | coma context create, coma use | coma connect, coma docker-context install |
| Selected with | coma --context <name>, COMA_CONTEXT | docker --context <name>, DOCKER_CONTEXT |
| Stored in | COMA's config and state | Docker'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 disconnectcoma connect --no-switchinstalls thecomaDocker context without making it current. Use it per command withdocker --context coma ….coma docker-context install --machine dev --engine dockeradds a Docker context fixed to one machine and engine, namedcoma-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
comaalready exists and COMA did not create it,coma connectstops withdocker_context_conflict;--replacetakes it over. DOCKER_HOSTandDOCKER_CONTEXToverride the Docker CLI's current context.coma connectwarns when either is set.
For tools that ignore Docker contexts, see Tools that ignore Docker contexts.