Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot pull image on windows #347

Closed
vxsx opened this issue Mar 14, 2017 · 20 comments
Closed

Cannot pull image on windows #347

vxsx opened this issue Mar 14, 2017 · 20 comments

Comments

@vxsx
Copy link

vxsx commented Mar 14, 2017

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

@ghost
Copy link

ghost commented Apr 4, 2017

Same problem here using dockerode 2.4.3 and docker 17.04.0-ce-rc2

@igor-lemon
Copy link

+1

@pashist
Copy link

pashist commented May 10, 2017

Same issue
Windows 10
Docker version 17.03.1-ce
dockerode 2.4.3

@nlaplante
Copy link

Same issue. Same config as @pashist

@nlaplante
Copy link

I'm still baffled with this. I'm not sure if it's an issue from dockerode or docker-modem or Docker itself. If I try again and again, sometimes images will pull successfully. But most of the time (9 times out of 10) it fails with context canceled.

I also tried without using modem.followProgress and the error still happens.

@eikster-dk
Copy link

This also happens in "node-docker-api" npm package that uses docker-modem, so i think this issue is a docker-modem issue.

@xblackhand
Copy link

xblackhand commented Jun 29, 2017

I was playing around with the modem.js to see why the pull function from dockerode was giving me a 'Error: context canceled' message. I got the pull to work with various images by commenting out req.end() on line 238. The typeof data === "string" was evaluating to true for the if-statement req.end() was in.

Not sure what repercussions this will have, but hope it gives the contributors an idea where to start to fix this correctly.

@nlaplante
Copy link

nlaplante commented Jun 30, 2017

Tried commenting out req.end() as suggested by @xblackhand but it broke other functionality like listing images & containers (timeout). BTW on docker-modem v1.0.0, the line # is 234 and not 238.

BTW the context canceled error can be seen in Docker's logs:

[20:15:29.322][ApiProxy       ][Info   ] proxy >> POST /images/create?fromImage=SOME_URL&tag=latest
[20:15:29.322][ApiProxy       ][Info   ] Dial Hyper-V socket 12c0044b-672b-4f86-8eaa-ff33ae68bac4:23a432c2-537a-4291-bcb5-d62504644739
[20:15:29.322][ApiProxy       ][Info   ] Successfully dialed Hyper-V socket 12c0044b-672b-4f86-8eaa-ff33ae68bac4:23a432c2-537a-4291-bcb5-d62504644739
[20:15:29.322][ApiProxy       ][Info   ] Cancel connection...
[20:15:29.769][ApiProxy       ][Info   ] proxy << POST /images/create?fromImage=SOME_URL&tag=latest```

@nlaplante
Copy link

Maybe this is related to this docker-modem issue (Requests that return HttpDuplex (eg docker exec start) hang when using named pipe on windows.)?

@brucedjones
Copy link

Any update on this?

@masaeedu
Copy link

Not 100% sure, but I think the issue might be that you actually have to wait for the response output from HTTP request to finish before you can consider the image to have been fully pulled. I have a Docker client library that I autogenerate from the Docker swagger API here and ran into the same issue: I was assuming the moment I got a response from the server I was good to go, whereas in fact I need to consume the output stream and only once that is done can I consider the image pulled.

@sochix
Copy link

sochix commented Nov 7, 2017

+1

1 similar comment
@langk
Copy link

langk commented Jan 12, 2018

+1

@rssk
Copy link

rssk commented Mar 30, 2018

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!

@KingRial
Copy link

KingRial commented Aug 9, 2018

Here the great workaround described by @rssk using basic authentication and private registry:

var clientRequest = http.request({
  socketPath: '//./pipe/docker_engine',
  path: '/images/create?fromImage=' + REGISTRY_HOST + '%2F' + IMAGE_NAME + '&tag=' + IMAGE_TAG,
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'X-Registry-Auth': new Buffer(JSON.stringify({ username: REGISTRY_USERNAME, password: REGISTRY_PASSOWRD, serveraddress: REGISTRY_HOST})).toString('base64')
  }
}, (res) => {
  res.setEncoding('utf8');
  res.on('data', data => console.log(data));
  res.on('error', data => console.error(data));
});
clientRequest.end();

@apocas
Copy link
Owner

apocas commented Aug 29, 2018

Is this still an issue?

I'm able to run the image pull test on Windows.
https://github.com/apocas/dockerode/blob/master/test/docker.js#L184

Using Windows 10 and latest Docker version.

@pofallon
Copy link

I believe it may have been resolved. I was also experiencing this error previously, but with everything at the latest version it now works.

@bj00rn
Copy link

bj00rn commented Dec 3, 2018

@apocas still an issue for me.
"dockerode": "2.5.7",
Docker Version 18.06.1-ce-win73 (19507)
Win 10

@bj00rn
Copy link

bj00rn commented Dec 4, 2018

Can confirm this issue with Docker Version 2.0.0.0-win81 (29211) (Engine 18.09.0) too

george3447 added a commit to george3447/docker-run that referenced this issue Jun 14, 2020
* 📦 NEW: add unit test for config utils

* 👌 IMPROVE: config-util test cases

* 👌 IMPROVE: add seperate error types for empty array and empty file

* 📦 NEW: add test cases for settings

* 👌 IMPROVE:  change operation class to abstract class and implement all operations

* 📦 NEW: add test cases for common list methods

* 👌 IMPROVE: add npm test for ci

* 📦 NEW: add github action for testing

* 🐛 FIX: pull test image before running list test cases

* 🐛 FIX: run suiteSetup via dockerode image pull callback

* 🐛 FIX: change nginx:alpine to nginx:latest to support windows

* 🐛 FIX: remove macos from github runner os as docker support is missing

* 🐛 FIX: change nginx:alpine to m4rcu5/lighttpd to support windows

* 👌 IMPROVE: remove windows from test cases run due to apocas/dockerode#347
@apocas
Copy link
Owner

apocas commented Apr 5, 2021

Closing this one, reopen if needed.

@apocas apocas closed this as completed Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests