 			]
 		)
 	.then (container) ->
-		console.log('Starting updated supervisor container:', supervisorTag)
+		console.log('Starting updated supervisor container:', localImage)
 		container.startAsync(
 			Privileged: true
 			Binds: [


			stream.on('end', resolve)
	.then ->
		console.log('Tagging updated supervisor:', updateImage)
		docker.getImage(updateImage).tagAsync(
			repo: supervisorTag
			force: true
		)
	.then ->
		console.log('Creating updated supervisor container:', supervisorTag)
		docker.createContainerAsync(
			Image: supervisorTag
			Cmd: ['/start']
			Volumes:
				'/boot/config.json': '/mnt/mmcblk0p1/config.json'

Promise.promisifyAll(docker.getImage().__proto__)
Promise.promisifyAll(docker.getContainer().__proto__)

localImage = 'resin/rpi-supervisor'
remoteImage = config.REGISTRY_ENDPOINT + '/' + localImage

supervisorUpdating = Promise.resolve()
exports.update = ->
	# Make sure only one attempt to update the full supervisor is running at a time, ignoring any errors from previous update attempts
	supervisorUpdating = supervisorUpdating.catch(->).then -> 
		console.log('Fetching updated supervisor:', remoteImage)
		docker.createImageAsync(fromImage: remoteImage)
	.then (stream) ->
		return new Promise (resolve, reject) ->
			if stream.headers['content-type'] is 'application/json'
