Skip to main content

atmos.devcontainer

The atmos.devcontainer function runs atmos devcontainer through the current Atmos executable. Use it to start, stop, rebuild, and run commands in development containers from automation.

Usage​

atmos.devcontainer(
*positionals,
flags = {},
args = [],
working_directory = ...,
env = ...,
output = "stream",
check = True,
)

Subcommands​

Pass the subcommand and any positional arguments as strings before the keyword arguments. The call atmos.devcontainer("start", "default") runs atmos devcontainer start default.

SubcommandPurpose
listList available devcontainers.
configShow devcontainer configuration.
startStart a devcontainer.
stopStop a running devcontainer.
rebuildRebuild a devcontainer.
removeRemove a devcontainer.
execExecute a command in a running devcontainer.
logsShow logs from a devcontainer.
attachAttach to a running devcontainer.
shellLaunch a shell in a devcontainer.

See the atmos devcontainer command reference for the complete list of subcommands and flags.

note

The devcontainer command is experimental, so each call prints the experimental notice. The attach and shell subcommands, and exec with the interactive flag, need a terminal, so use exec with a command after the -- separator to run non-interactively.

Arguments​

*positionals

(Optional) Strings placed on the command line right after devcontainer, in order: the subcommand and its positional arguments, such as the devcontainer name. Every value must be a string.

flags

(Optional) A dictionary of command-line options; see flag translation. The instance key becomes --instance and selects a named instance of the devcontainer. Other keys include identity for start, rebuild, and shell, follow and tail for logs, and timeout and rm for stop.

args
(Optional) A list or tuple of strings appended after the flags.
working_directory, env, output, check

(Optional) See atmos.run for process options and defaults.

Options other than the positionals are keyword-only.

Returns​

A result with stdout, stderr, and exit_code. See atmos.run for output and error behavior.

Examples​

Start a devcontainer instance​

atmos.devcontainer("start", "geodesic", flags = {"instance": "ci"})

Run a command inside a running devcontainer​

atmos.devcontainer(
"exec", "geodesic",
flags = {"instance": "ci"},
args = ["--", "terraform", "version"],
)

Everything after the -- separator is the command to run. The call runs atmos devcontainer exec geodesic --instance=ci -- terraform version.

Run a job and clean up​

def run_in_devcontainer():
atmos.devcontainer("start", "geodesic", flags = {"instance": "ci"})
return atmos.devcontainer(
"exec", "geodesic",
flags = {"instance": "ci"},
args = ["--", "make", "test"],
output = "capture",
check = False,
)

outcome = run_in_devcontainer()
atmos.devcontainer("stop", "geodesic", flags = {"instance": "ci", "rm": True})
if outcome.exit_code != 0:
fail("Tests failed in the devcontainer:\n" + outcome.stdout)