Skip to main content
Run shell commands inside a Docker development container on your local machine. Commands can be run inline or saved as named aliases for reuse.

Syntax

lager exec [OPTIONS] [COMMAND] [EXTRA_ARGS]...

Options

OptionShortTypeDefaultDescription
--command TEXTstringRaw shell command to execute (e.g., 'make build')
--save-as TEXTstringSave the command under this alias for later use
--warn / --no-warnflag--warnWarn when overwriting a saved command
--env FOO=BARmultipleSet environment variable in the container
--passenv NAMEmultipleInherit environment variable from current shell
--mount NAME-mstringDocker volume to mount
--interactive / --no-interactive-iflag--interactiveKeep STDIN open
--tty / --no-tty-tflag--ttyAllocate a pseudo-TTY
--user TEXT-ustringcurrent UIDUser to run as in the container
--group TEXT-gstringcurrent GIDGroup to run as in the container
--verbose-vflagShow the full Docker command being executed
--helpShow help message and exit

Arguments

ArgumentDescription
COMMANDName of a previously saved command to run
EXTRA_ARGSAdditional arguments appended to the command at runtime

Prerequisites

A development environment must be created first:
lager devenv create
This configures the Docker image, mount directory, and shell used by lager exec.

Command Reference

Run an Inline Command

lager exec --command 'make build'
lager exec --command 'pytest tests/ -v'

Save a Command for Reuse

lager exec --command 'make clean && make build' --save-as build

Run a Saved Command

lager exec build

Append Extra Arguments

# Runs: make clean && make build --verbose --debug
lager exec build --verbose --debug

Pass Environment Variables

# Set explicitly
lager exec --command 'make build' --env CFLAGS="-O2" --env DEBUG=0

# Inherit from current shell
lager exec --command 'make build' --passenv PATH --passenv HOME

How It Differs from Other Commands

CommandTargetPurpose
lager execLocal Docker containerRun build/test commands in a reproducible environment
lager pythonRemote Lager BoxExecute Python scripts that interact with test equipment
lager sshRemote Lager BoxOpen an interactive SSH shell for box administration

Saved Command Management

Saved commands are stored in the devenv section of your .lager config. Use lager devenv to manage them:
lager devenv commands         # List saved commands
lager devenv add <name> "<cmd>"   # Add a command
lager devenv delete <name>    # Remove a command
lager devenv terminal         # Open an interactive shell in the container

Examples

# One-off build
lager exec --command 'make -j4'

# Save and reuse a test command
lager exec --command 'pytest tests/ --tb=short' --save-as test
lager exec test

# Run with verbose Docker output
lager exec --verbose --command 'gcc main.c -o main'

# Non-interactive mode for CI
lager exec --no-interactive --no-tty --command 'make check'

Notes

  • The container is created with --rm so it is removed after each command
  • Exit codes from the container are propagated to the CLI
  • Source code is mounted from your local filesystem into the container
  • Lager configuration (~/.lager) is mounted into the container when present
  • The COMMAND argument and --command option are mutually exclusive; use one or the other