1

I am running docker using dockerode's run command.

    let dockerEvent = docker.run('imageName', [], process.stdout, function(err) {
    if(err) {
        console.log("Error while starting docker", err);
    }
});

I need to do something once the docker container is running. How do I know when the docker container is running using dockerode library?

Ankit Arora
  • 110
  • 3
  • 16
  • If you weren't using Docker and instead used, say, `child_process.exec()`, how would you tell if the subprocess was running? Can you do the same thing with Docker? – David Maze Aug 09 '21 at 13:00
  • @DavidMaze Possible through the exit code "docker run" retuns. docker provides a web api/unix socket, where you can listen for events via `curl --unix-socket /var/run/docker.sock http://localhost/events` https://docs.docker.com/engine/api/v1.41/#operation/SystemEvents Should not be hard do adopt that into node.js and listen for specific events (The curl example was for test, run it and start a new container and see what it logs) or with "dockerode" -> `docker.getEvents(options)` – Marc Aug 09 '21 at 13:54

0 Answers0