Skip to content

feat: add exec command for running containers - #7

Merged
pigmej merged 1 commit into
pigmej:mainfrom
kacpersaw:kacpersaw/add-exec
Sep 20, 2026
Merged

pigmej merged 1 commit into
pigmej:mainfrom
kacpersaw:kacpersaw/add-exec

Conversation

@kacpersaw

Copy link
Copy Markdown
Contributor

Summary

Adds ocdev exec to run commands inside an existing container without opening an interactive shell or defining a recipe task.

ocdev exec demo -- uname -a
ocdev exec demo --cwd /home/dev/workspace/app -- npm test
printf 'hello\n' | ocdev exec demo -- cat

What was added

  • Execution as dev, with /home/dev as the default directory and optional --cwd.
  • Direct argument forwarding after --, including the program’s own flags.
  • Raw stdin, separate stdout/stderr, and command exit-code forwarding.
  • Cancellation handling, documentation, and make test-exec.

There is no ocdev-level --json, implicit shell, pseudo-terminal, or command/output logging. Interactive sessions still use ocdev shell.

Behavior and safety

Containers must already be running. Exec holds the environment lock and checks pinned UUIDs for recipe-managed containers.

Interruption cleans up the local Incus client, but does not guarantee the guest command has stopped. The abbreviation ex is now ambiguous with export; use exec explicitly.

Testing

  • make test passed: 115 unit/integration tests plus version regressions.
  • Includes 13 exec test groups covering arguments, binary streams, stdin, exit codes, locking, UUID checks, and cancellation.
  • Verification used a clean HOME and a PATH without real Incus or Python. No live container tests were run.

@pigmej
pigmej merged commit c5e80e7 into pigmej:main Sep 20, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants