Skip to content

Stream output of Docker run #17

Open

Description

@iddan

I would like to be able to call docker run and use the output as a stream. For example: waiting for a specific log emitted by a server process.
Thank you for this wonderful library.

Activity

  1. mattqs commented on Jul 26, 2020

    @mattqs
    Contributor

    Does this help?

    Added the ability to stream 'stdout' and 'stderr' from docker command.

    2cd8af5

  2. iddan commented on Jul 26, 2020

    @iddan
    Author

    Hey, if I understand correctly this is the "echo" option. I meant getting a stream that is accessible for the user.

    API Proposals

    Async iterator:

    const run = docker.command(`run exampleImage`, { stream: true });
    for (const await line of run) {
        // use line here
    }

    Old fashioned stream

    const run = docker.command(`run exampleImage`, { stream: true });
    run.stdout.on("data", (buffer) => {
        const line = buffer.toString();
        // use line here
    })
  3. kuboraam commented on Jul 8, 2022

    @kuboraam

    Hey, if I understand correctly this is the "echo" option. I meant getting a stream that is accessible for the user.

    API Proposals

    Async iterator:

    const run = docker.command(`run exampleImage`, { stream: true });
    for (const await line of run) {
        // use line here
    }

    Old fashioned stream

    const run = docker.command(`run exampleImage`, { stream: true });
    run.stdout.on("data", (buffer) => {
        const line = buffer.toString();
        // use line here
    })

    +1 this is a good idea @iddan . did you find a solution for this? I am trying to use this to execute some terraform scripts where it is expected to take a while for the docker command to run. however, i would like to receive the output somehow as the process is running so i can stream it back to the user via rabbitmq.

  4. Ciao121 commented on Oct 30, 2023

    @Ciao121

    +1 for this

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions