Skip to content

Instantly share code, notes, and snippets.

@dbenchi
Last active November 25, 2016 13:54
Show Gist options
  • Save dbenchi/db0b86ef88d40a84e737189bc9854ec7 to your computer and use it in GitHub Desktop.
Save dbenchi/db0b86ef88d40a84e737189bc9854ec7 to your computer and use it in GitHub Desktop.
snapshotAll.js
GruntfileUtils.prototype.snapshotAll = function() {
const grunt = this.grunt;
return function() {
const done = this.async();
const docker = new Docker(dockerodeConfig()[grunt.option('docker')]);
docker
.listContainers((err, containers) => {
containers.forEach(containerInfo => {
docker.getContainer(containerInfo.Id)
.commit({ comment: containerInfo.Image, repo: containerInfo.Image.split(/:/)[0], tag: 'snapshot', Labels: { 'snapshot': 'snapshot'} },
function(err, stream) {
if (err) {
done(false);
}
done(true);
});
})
})
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment