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

feat: check docker version #310

Merged
merged 1 commit into from
Mar 18, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;