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

Pull image promise resolves before image available. #550

Closed
SkeLLLa opened this issue Dec 23, 2019 · 3 comments
Closed

Pull image promise resolves before image available. #550

SkeLLLa opened this issue Dec 23, 2019 · 3 comments

Comments

@SkeLLLa
Copy link

SkeLLLa commented Dec 23, 2019

Hi. Here's an example for reproduce the bug.

const Docker = require('dockerode');
const docker = new Docker({socketPath: '/var/run/docker.sock'});

(async () => {
  try {
    await docker.pull('ubuntu:latest', {});
    const data = await docker.run('ubuntu:latest', ['bash', '-c', 'uname -a'], [process.stdout, process.stderr], {Tty:false});
    process.stdout.write('Ok', data);
  } catch(err) {
    console.error('Error', err);
  }
})()

Steps to reproduce:

  1. Exec docker system prune -a to remove all images and perform clean test.
  2. Run code above for the first time
Error: (HTTP code 404) no such container - No such image: ubuntu:latest 
    at /test-app/node_modules/docker-modem/lib/modem.js:296:17
    at getCause (/test-app/node_modules/docker-modem/lib/modem.js:326:7)
    at Modem.buildPayload (/test-app/node_modules/docker-modem/lib/modem.js:295:5)
    at IncomingMessage.<anonymous> (/test-app/node_modules/docker-modem/lib/modem.js:270:14)
    at IncomingMessage.emit (events.js:215:7)
    at endReadableNT (_stream_readable.js:1183:12)
    at processTicksAndRejections (internal/process/task_queues.js:80:21) {
  reason: 'no such container',
  statusCode: 404,
  json: { message: 'No such image: ubuntu:latest' }
}
  1. Run for the second time - and all will be fine.

I've also check if that's not some local docker issue. If I run docker pull ubuntu && docker images and ubuntu image is present in command output. However if I run example code above and stop in a breakpoint just after await docker.pull('ubuntu:latest', {}); and run docker images, then ubuntu image appears there after 3-4 seconds.

@SkeLLLa SkeLLLa closed this as completed Dec 23, 2019
@gajus
Copy link

gajus commented Aug 17, 2020

@SkeLLLa What was the solution?

@gajus
Copy link

gajus commented Aug 17, 2020

Seems like you need to wait until onFinish.

#357 (comment)

@Tzvetelin88
Copy link

Tzvetelin88 commented Feb 19, 2024

Same problem here.

await docker.pull(image)

function completes, image still not there and after some time image becomes available.

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

3 participants