Skip to content

Commit 323ff43

Browse files
committed
improve usability by guessing API options based on defined parameters
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
1 parent 47ac3bc commit 323ff43

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

lib/docker-client.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,11 @@ export class DockerClient {
478478
): Promise<void> {
479479
const response = await this.api.upgrade(
480480
`/containers/${id}/attach`,
481-
options,
481+
options || {
482+
stdout: stdout != null,
483+
stderr: stderr != null,
484+
stream: stdout != null || stderr != null,
485+
},
482486
);
483487
switch (response.content) {
484488
case DOCKER_RAW_STREAM:
@@ -1641,6 +1645,11 @@ export class DockerClient {
16411645
stderr: stream.Writable | null,
16421646
execStartConfig?: types.ExecStartConfig,
16431647
): Promise<void> {
1648+
// If no output streams and Detach not explicitly set, force detached mode
1649+
if (stdout === null && stderr === null && execStartConfig?.Detach === undefined) {
1650+
await this.api.post(`/exec/${id}/start`, { ...execStartConfig, Detach: true });
1651+
return;
1652+
}
16441653
if (execStartConfig?.Detach) {
16451654
await this.api.post(`/exec/${id}/start`, execStartConfig);
16461655
} else {

0 commit comments

Comments
 (0)