-
-
Notifications
You must be signed in to change notification settings - Fork 483
Open
Description
When using the executeCommand function to send commands to a Docker container, the command execution sometimes fails. Instead of the expected command being executed, the following JSON object appears in the stream:
{"stdin":true,"stream":true,"stdout":false,"hijack":true,"stderr":false}
This causes the command to be misinterpreted and the container to return an "Unknown command" error, rather than executing the intended command.
Steps to Reproduce:
- Call the executeCommand function with the appropriate container ID and a command.
- Observe that sometimes, instead of the intended command, the stream includes the JSON configuration as shown above.
export const executeCommand = async (
containerId: string,
cmd: string
): Promise<void> => {
const container = docker.getContainer(containerId);
const stream = await container.attach({
stdin: true,
stream: true,
stdout: false,
hijack: true,
stderr: false,
});
stream.write(cmd + `\n`);
stream.end();
};
example logs:
Logs: Example of what happens in the container log:
[09:49:04] [Server thread/INFO]: [Server] y
say y
[09:49:05] [Server thread/INFO]: [Server] y
say y
[09:49:06] [Server thread/INFO]: [Server] y
say y
[09:49:08] [Server thread/INFO]: [Server] y
say y
[09:49:08] [Server thread/INFO]: [Server] y
say y
[09:49:09] [Server thread/INFO]: [Server] y
{"stdin":true,"stream":true,"stdout":false,"hijack":true,"stderr":false}say y
[09:49:10] [Server thread/INFO]: Unknown command. Type "/help" for help.
Metadata
Metadata
Assignees
Labels
No labels