Syntax
Options
Arguments
Prerequisites
A development environment must be created first:lager exec.
Command Reference
Run an Inline Command
Save a Command for Reuse
Run a Saved Command
Append Extra Arguments
-- before extra arguments that start with a dash. Without it, lager exec
takes an argument that matches one of its own options, such as --verbose, for
itself.
Pass Environment Variables
--passenv copies the value from your shell into the container. Do not pass
PATH: the host value replaces the PATH of the image, and the container then
does not find its own tools.
Running in CI
lager exec reads the CI environment variables before it starts a container. In
a job on one of these CI systems, it runs the command in place, with no
container:
A job on one of these systems usually runs inside the devenv image already.
The variables name the CI system, not the container, so the CLI also checks
whether this process is in one. It looks for
/.dockerenv,
/run/.containerenv, the container environment variable, and a container
runtime in the cgroup of process 1.
The command runs in place only when both are true. A GitHub Actions or GitLab
CI job without a container: block runs on the runner itself. The CLI starts a
container there and prints one line to say so.
In place, the command runs as follows:
- The shell is the DEVENV
shellfrom.lager, or/bin/bash. - The command runs in the current directory.
mount_dirdoes not apply. - The command gets the environment of the job, plus
environmentfrom.lagerand each--env.--passenvhas no effect because the job environment is already present. - The exit code of the command is the exit code of
lager exec. --mount,--volume,--user, and--grouphave no effect. If you pass any of them, the CLI prints one warning line, for exampleWarning: --mount, --volume ignored: the command runs in the current container, so there is nothing to start.--interactiveand--ttyhave no effect.
Choosing the path yourself
LAGER_EXEC_IN_PLACE overrides the check. Set it to 1, true, or yes to
run the command in place, and to 0, false, or no to start a container.
Any other value is ignored, and the CLI falls back to what it detected.
LAGER_EXEC_IN_PLACE changes lager exec and nothing else. Box locking, the
lock holder, and the collision wait are the same with it set.
How It Differs from Other Commands
Saved Command Management
Saved commands are stored in the devenv section of your.lager config. Use lager devenv to manage them:
Examples
Notes
- The container is created with
--rmso it is removed after each command - Exit codes from the container are propagated to the CLI
- Every
LAGER*environment variable in your shell is passed into the container - Source code is mounted from your local filesystem into the container
- Lager configuration (
~/.lager) is mounted into the container when present - The
COMMANDargument and--commandoption are mutually exclusive; use one or the other

