ExecAgent is a C# library and framework for running commands inside Docker containers with real-time output streaming.
It provides a reusable core library (ExecAgent.Core) that can be used by multiple client applications, such as console apps, web GUIs, or desktop interfaces.
-
Execute commands in any running Docker container.
-
Stream stdout and stderr in real-time.
-
Retrieve command exit codes.
-
Designed for reuse across multiple clients:
- Console applications
- Web applications (ASP.NET, SignalR)
- Desktop GUI apps
-
Cross-platform: works wherever Docker and .NET are supported.
ExecAgent/
│
├─ ExecAgent.sln # Visual Studio solution
├─ ExecAgent.Core/ # Core library
├─ ExecAgent.TestApp/ # Test console application
└─ .gitignore
- ExecAgent.Core: The reusable library handling Docker exec commands and streaming output.
- ExecAgent.TestApp: Example console client that demonstrates how to use the library.
- Docker installed and running.
- .NET 10 SDK installed.
- Pull a lightweight test container:
docker pull alpine:latest
docker run -d --name execagent-test alpine:latest tail -f /dev/null- Update the container name in
ExecAgent.TestApp/Program.cs:
string containerName = "execagent-test";- Run the console app:
dotnet run --project ExecAgent.TestAppExpected output:
Starting ExecAgent test...
Streaming output:
StdOut: Hello ExecAgent
Execution finished with exit code: 0
- Add a reference to the Core library:
dotnet add reference ../ExecAgent.Core/ExecAgent.Core.csproj- Create a
DockerExecutorand execute commands:
var executor = new DockerExecutor();
var request = new ExecRequest
{
Container = "your-container-name",
Command = new[] { "your", "command" },
Tty = true
};
var session = await executor.CreateSessionAsync(request, CancellationToken.None);
await foreach (var output in session.StreamAsync(CancellationToken.None))
{
Console.WriteLine(output.Data);
}
var exitCode = await session.GetExitCodeAsync();
Console.WriteLine($"Command finished with exit code {exitCode}");- Create a new branch for features or bug fixes (
feature/xxx,bugfix/xxx). - Make your changes and test locally.
- Open a pull request against
main.
This project is open-source and licensed under the MIT License.
.NET, C#, Docker, Exec, Streaming, Cross-platform