support docker compose v2 (#16919)

Signed-off-by: yminer <yminer@vmmware.com>

Co-authored-by: yminer <yminer@vmmware.com>
This commit is contained in:
MinerYang 2022-05-30 15:19:01 +08:00 committed by GitHub
parent 93f3bb16d6
commit 1db7d6375a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -103,14 +103,19 @@ function check_docker {
} }
function check_dockercompose { function check_dockercompose {
if ! docker-compose --version &> /dev/null if [! docker compose version] &> /dev/null || [! docker-compose --version] &> /dev/null
then then
error "Need to install docker-compose(1.18.0+) by yourself first and run this script again." error "Need to install docker-compose(1.18.0+) or a docker-compose-plugin (https://docs.docker.com/compose/)by yourself first and run this script again."
exit 1 exit 1
fi fi
# docker-compose has been installed, check its version # either docker compose plugin has been installed
if [[ $(docker-compose --version) =~ (([0-9]+)\.([0-9]+)([\.0-9]*)) ]] if docker compose version &> /dev/null
then
note "$(docker compose version)"
# or docker-compose has been installed, check its version
elif [[ $(docker-compose --version) =~ (([0-9]+)\.([0-9]+)([\.0-9]*)) ]]
then then
docker_compose_version=${BASH_REMATCH[1]} docker_compose_version=${BASH_REMATCH[1]}
docker_compose_version_part1=${BASH_REMATCH[2]} docker_compose_version_part1=${BASH_REMATCH[2]}