Skip to content

container.attach stuck when using stdin #819

Description

@carl-sauter

Hey there, I am trying to connect to a running container using attach. However when I use stdin: true it hangs in this line.

This is my code:

const Docker = require("dockerode");

const docker = new Docker({socketPath: '/var/run/docker.sock'});

const container = docker.getContainer('56cd62bc09ba8e46730f681bfd4cd08b741a6b98db9d676fb6af06c90ceb24b9')
const stream = await container.attach({
    stdin: true,
    stdout: true,
    stderr: true,
    stream: true,
})

stream.pipe(process.stdout)

setInterval(() => {
    stream.write("velocity info\n")
}, 3000)

I started the container using the following command

docker run -itd --rm --network host -v ... azul/zulu-openjdk-alpine:21-jre-headless ./start.sh

Using docker attach <container_id> works just fine for in- and output. However the code gets stuck at container.attach when using stdin: true. With only stdout and stderr it works fine. But I also need the send input.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions