dockerode: Cannot pull image on windows

This snippet:

return new Promise((resolve, reject) => {
        docker.pull('any image', (error, stream) => {
            docker.modem.followProgress(stream, (error, output) => {
                if (error) {
                    reject(error);
                    return;
                }
                resolve(output);
            }, (event) => console.log(event));
        });
})

always rejects on windows with “context canceled” as error message. The Docker logs show something like this:

[16:57:26.956][ApiProxy       ][Info   ] proxy >> POST /v1.26/images/create?fromImage=postgres&tag=latest
[16:57:26.957][ApiProxy       ][Info   ] Dial Hyper-V socket 6f1ec07b-ba85-4cb4-ad22-d0e2577b8f24:23a432c2-537a-4291-bcb5-d62504644739
[16:57:26.958][ApiProxy       ][Info   ] Successfully dialed Hyper-V socket 6f1ec07b-ba85-4cb4-ad22-d0e2577b8f24:23a432c2-537a-4291-bcb5-d62504644739
[16:58:08.637][ApiProxy       ][Info   ] Cancel connection...
[16:58:08.641][ApiProxy       ][Info   ] proxy << POST /v1.26/images/create?fromImage=postgres&tag=latest

Normal docker pull imagename works inside powershell Latest Docker for Windows.

It might be a problem with Docker for Windows itself, but any help would be really appreciated. Same snippet works correctly on mac and linux

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 11
  • Comments: 20 (2 by maintainers)

Commits related to this issue

Most upvoted comments

This was plaguing our Windows builds so I dug a bit, the results can be found here as it’s an issue w/ docker-modem. Super interesting the Docker daemon seems to respond differently on win vs osx, but I assume that’s due to HyperV differences?

Either way, if you’re hurting for a solution you can just do pulls with plain ol’ node http:

const http = require('http');

const options = {
  socketPath: '//./pipe/docker_engine',
  path: '/v1.37/images/create?fromImage=coinstac%2Fcoinstac-base',
  method: 'POST',
};

const callback = res => {
  console.log(`STATUS: ${res.statusCode}`);
  res.setEncoding('utf8');
  res.on('data', data => console.log(data));
  res.on('error', data => console.error(data));
};

const clientRequest = http.request(options, callback);
clientRequest.end();

Hope that helps!