Can't execute command with bash shell
- Dominant language
- C#
- Stars
- 2.4k
- Forks
- 416
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to automate running commands with `docker exec`. I have an example of a command that works from the command line, but can't get working in Docker.DotNet. With my container already running I opened a command line and ran: `docker exec -it containerId bash -c "apt-get update"`. This command is successful and I can see the output from the command in the terminal window.
Then, I tried doing the same as:
```
ContainerExecCreateParameters execParams = new()
{
AttachStderr = true,
AttachStdout = true,
Cmd = new[] { "//bin//bash", "apt-get update" }
};
var exec = await this.dockerClient.Exec.ExecCreateContainerAsync(containerId, execParams);
var stream = await this.dockerClient.Exec.StartAndAttachContainerExecAsync(exec.ID, false);
var output = await stream.ReadOutputToEndAsync(new CancellationToken());
```
Instead of getting the exepected output of `apt-get update`, I get the error message: `(OCI runtime exec failed: exec failed: unable to start container process: exec: "apt-get update": executable file not found in $PATH: unknown , )`.
I believe this error may be due to trying to execute the command not in the bash shell, but haven't found any examples or docs that demonstrate how to properly execute a command in the bash shell using Docker.DotNet.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.