Skip to content

Conversation

githoober
Copy link

@githoober githoober commented Jul 14, 2025

Fixes #22

@githoober githoober changed the title Add support for executing commands inside running Docker containers Fixes #22 Add support for executing commands inside running Docker containers Jul 14, 2025
@githoober githoober changed the title Fixes #22 Add support for executing commands inside running Docker containers Add support for executing commands inside running Docker containers Jul 14, 2025
@githoober
Copy link
Author

@ckreiling, please, please check at your earliest convenience. Thanks. It is working on my side.

- `remove_container`
- `exec_in_container`

#### New: `exec_in_container`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have this "New" section for other tools - please remove


if args.detach:
result = {"status": "detached", "exec_id": exec_result.id}
elif args.stream:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the benefit to supporting stream if we wait to collect all the output and return a response to the LLM? This seems like an option that shouldn't be relevant to this implementation

Comment on lines +413 to +427
exec_params = {
"cmd": args.command,
"stdout": True,
"stderr": True,
"stdin": args.stdin,
"tty": args.tty,
"privileged": args.privileged,
"user": args.user,
"environment": args.environment,
"workdir": args.working_dir,
"detach": args.detach,
"stream": args.stream,
"socket": args.socket,
"demux": args.demux,
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just be a call to args.model_dump(). What I've done historically is make the Pydantic model (in this case ExecInContainerInput) map directly to the input kwargs on the corresponding Docker client, and use the same defaults as the client. it ends up being cleaner & clearer to the implementor AND the model what the default behavior is, at the cost of a little redundancy

Comment on lines +415 to +416
"stdout": True,
"stderr": True,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LLM should be able to set these options; perhaps it doesn't care about the output and can save some input tokens by opting to skip stdout and stderr

@ckreiling
Copy link
Owner

Hello @githoober thank you for your contributions! I've left a few comments above that should be addressed before I am comfortable merging these changes. Mainly I am looking to align your additions with existing best-practices I've established

@ckreiling
Copy link
Owner

@githoober let me know if you want any further guidance to get this merged!

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.

Ability to Run Arbitrary Commands Inside Running Docker Container
2 participants