apocas / dockerode

Docker + Node = Dockerode (Node.js module for Docker's Remote API)
Apache License 2.0
4.36k stars 461 forks source link

TypeError: this.modem.Promise is not a constructor #773

Open mirkobertone opened 3 months ago

mirkobertone commented 3 months ago

Hello, I'm trying to stop a container but I receive this error. I can't understand what I'm doing wrong. Someone can help me?

docker.listContainers(function (err, containers) {
  containers.forEach(function (containerInfo) {
    console.log(containerInfo.Names[0]);
    if (containerInfo.Names[0] === "/grpc-nest-test") {
      const cnt = docker.getContainer(containerInfo.Id);
      console.log("name", containerInfo.Names[0], "id", cnt.id);
      cnt
        .stop()
        .then(() => {
          console.log("Container stopped successfully.");
        })
        .catch((err) => {
          console.error("Error stopping container:", err);
        });
    }
  });
});

TypeError: this.modem.Promise is not a constructor at Container.stop (/home/mirkuz/dev/tmp/node_modules/dockerode/lib/container.js:603:12) at /home/mirkuz/dev/tmp/app.js:239:10 at Array.forEach () at Object.callback (/home/mirkuz/dev/tmp/app.js:233:14) at /home/mirkuz/dev/tmp/node_modules/dockerode/lib/docker.js:432:12 at Modem.buildPayload (/home/mirkuz/dev/tmp/node_modules/docker-modem/lib/modem.js:398:7) at IncomingMessage. (/home/mirkuz/dev/tmp/node_modules/docker-modem/lib/modem.js:346:16) at IncomingMessage.emit (node:events:529:35) at endReadableNT (node:internal/streams/readable:1400:12) at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

mirkobertone commented 3 months ago

I made a mistake: it work perfectly. This issue can be closed