Skip to content
This repository has been archived by the owner on Dec 16, 2021. It is now read-only.

Commit

Permalink
feat: check docker version (#310)
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Shuplenkov authored Mar 18, 2021
1 parent faeb1b2 commit f7092b1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/docker/DockerCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,22 @@ class DockerCompose {
throw new Error('Docker Compose is not installed');
}

// check docker version
const dockerVersion = await new Promise((resolve, reject) => {
this.docker.version((err, data) => {
if (err) {
return reject(err);
}

return resolve(data.Version);
});
});

if (semver.lt(dockerVersion.trim(), DockerCompose.DOCKER_MIN_VERSION)) {
throw new Error(`Update Docker to version ${DockerCompose.DOCKER_MIN_VERSION} or higher`);
}

// check docker compose version
const { out: version } = await dockerCompose.version();
if (semver.lt(version.trim(), DockerCompose.DOCKER_COMPOSE_MIN_VERSION)) {
throw new Error(`Update Docker Compose to version ${DockerCompose.DOCKER_COMPOSE_MIN_VERSION} or higher`);
Expand All @@ -331,5 +347,6 @@ class DockerCompose {
}

DockerCompose.DOCKER_COMPOSE_MIN_VERSION = '1.25.0';
DockerCompose.DOCKER_MIN_VERSION = '20.10.0';

module.exports = DockerCompose;

0 comments on commit f7092b1

Please sign in to comment.