Skip to content

Commit f2059f1

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 f2059f1

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

lib/docker-client.ts

Lines changed: 17 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,18 @@ 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 (
1650+
stdout === null &&
1651+
stderr === null &&
1652+
execStartConfig?.Detach === undefined
1653+
) {
1654+
await this.api.post(`/exec/${id}/start`, {
1655+
...execStartConfig,
1656+
Detach: true,
1657+
});
1658+
return;
1659+
}
16441660
if (execStartConfig?.Detach) {
16451661
await this.api.post(`/exec/${id}/start`, execStartConfig);
16461662
} else {

0 commit comments

Comments
 (0)