dockerode icon indicating copy to clipboard operation
dockerode copied to clipboard

Improve docker pull behaviour

Open skjnldsv opened this issue 3 years ago • 5 comments

Hey! Thank you so much for this library. I really enjoyed working with it and will keep doing so! :pray:

I had some issues about docker pull and async/await race conditions Following #357, I had to implement that

console.log('Pulling images... ⏳')
await new Promise((resolve, reject): any => docker.pull(SERVER_IMAGE, (err, stream) => {
	// https://github.com/apocas/dockerode/issues/357
	docker.modem.followProgress(stream, onFinished)
	function onFinished(err, output) {
		if (!err) {
			resolve(true)
			return
		}
		reject(err)
	}
}))
console.log(`└─ Done`)

Unfortunately, I think we could largely improve from the current behaviour. The code I would like to see would be the following:

console.log('Pulling images... ⏳')
await docker.pull(SERVER_IMAGE)
console.log(`└─ Done`)

Could you explain the reasoning behind this implementation @apocas ? :)


Error details ```js Error: (HTTP code 404) no such container - No such image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest at /home/runner/work/viewer/viewer/node_modules/docker-modem/lib/modem.js:336:17 at getCause (/home/runner/work/viewer/viewer/node_modules/docker-modem/lib/modem.js:366:7) at Modem.buildPayload (/home/runner/work/viewer/viewer/node_modules/docker-modem/lib/modem.js:335:5) at IncomingMessage. (/home/runner/work/viewer/viewer/node_modules/docker-modem/lib/modem.js:303:16) at IncomingMessage.emit (node:events:402:35) at IncomingMessage.emit (node:domain:475:12) at endReadableNT (node:internal/streams/readable:1343:12) at processTicksAndRejections (node:internal/process/task_queues:83:21) { reason: 'no such container', statusCode: 404, json: { message: 'No such image: ghcr.io/nextcloud/continuous-integration-shallow-server:latest' } ```

skjnldsv avatar Nov 15 '22 14:11 skjnldsv

any update on this issue @apocas

deefactorial avatar Oct 18 '23 17:10 deefactorial

+1, would love to see an update on this. Ideally, callbacks wouldn't be required at all.

scubbo avatar Oct 26 '23 20:10 scubbo

+1. I see

await docker.pull(image)

is supported, but it actually doesn't work properly. Function completes, but the image is still not there, and after some time it appears.

Tzvetelin88 avatar Feb 19 '24 14:02 Tzvetelin88