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.
| Subcommand | Purpose |
|---|---|
list | List available devcontainers. |
config | Show devcontainer configuration. |
start | Start a devcontainer. |
stop | Stop a running devcontainer. |
rebuild | Rebuild a devcontainer. |
remove | Remove a devcontainer. |
exec | Execute a command in a running devcontainer. |
logs | Show logs from a devcontainer. |
attach | Attach to a running devcontainer. |
shell | Launch a shell in a devcontainer. |
See the atmos devcontainer command reference for the complete list of subcommands and
flags.
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
instancekey becomes--instanceand selects a named instance of the devcontainer. Other keys includeidentityforstart,rebuild, andshell,followandtailforlogs, andtimeoutandrmforstop.args- (Optional) A list or tuple of strings appended after the flags.
working_directory,env,output,check(Optional) See
atmos.runfor 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)
Related
atmos.runruns any Atmos command from an argument list.atmos devcontainerdocuments every subcommand and flag.- Atmos Automation Language and the script step