apocas / docker-modem

Docker Remote API network stack driver.
Apache License 2.0
234 stars 112 forks source link

stream is null during docker pull and not handled #93

Open KBPratap opened 6 years ago

KBPratap commented 6 years ago

I have this issue, on some user machines this works fine but for some it throws the following errors:

TypeError: Cannot read property 'pipe' of null
    at Modem.followProgress (/data/app/node_modules/docker-modem/lib/modem.js:316:10)

Following is the implementation

docker.pull(repoTag, function(err, stream) {
    docker.modem.followProgress(stream, onFinished, onProgress);
    function onFinished(err, output) {
        ....
    }
    function onProgress(event) {
        ....
    }
}

Docker Version 18.03.1-ce-mac65 (24312)

apocas commented 5 years ago

Could you give more details? Can't replicate this.

coco-super commented 4 years ago

@nuxlli @rmg @knownasilya @Stuk @ekristen I have this issue, on some user machines this works fine but for some it throws the following errors. I don't know where the problem is,Can you give me some advice

dockerode version 3.0.2

docker.modem.followProgress(stream, onFinished, onProgress);

function buildImage(dockerBuildDir, dockerfilePath, imageTag) {
  return new Promise((resolve, reject) => {
    var tarStream = tar.pack(dockerBuildDir);
    docker.buildImage(tarStream, {
      dockerfile: path.relative(dockerBuildDir, dockerfilePath),
      t: imageTag
    }, (error, stream) => {
      containers.add(stream);

      if (error) { reject(error); }
      else {
        stream.on('error', (e) => {
          containers.delete(stream);
          reject(e);
        });
        stream.on('end', function () {
          containers.delete(stream);
          resolve(imageTag);
        });
      }
      followProgress(stream, (err, res) => err ? reject(err) : resolve(res));
    });
  });
}

stream.pipe(parser);
         ^

TypeError: Cannot read property 'pipe' of null
    at Modem.followProgress (/Users/ellison/fun/node_modules/docker-modem/lib/modem.js:379:10)
    at followProgress (/Users/ellison/fun/lib/docker.js:295:16)
    at docker.buildImage (/Users/ellison/fun/lib/docker.js:999:7)
    at /Users/ellison/fun/node_modules/dockerode/lib/docker.js:295:9
    at /Users/ellison/fun/node_modules/docker-modem/lib/modem.js:302:7
    at IncomingMessage.<anonymous> (/Users/ellison/fun/node_modules/docker-modem/lib/modem.js:321:9)
    at IncomingMessage.emit (events.js:187:15)
    at IncomingMessage.EventEmitter.emit (domain.js:442:20)
    at endReadableNT (_stream_readable.js:1092:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
evanstachowiak commented 2 months ago

I know this is very old, but I had the same issue and it turned out the /var/run/docker.sock did not exist. Once that was corrected, everything worked fine.