As you know may noticed, Docker changed the name of compose from docker-compose
to docker compose
I have a Makefile that calls docker-compose
run:
docker-compose up --build
However I want to make my Makefile portable, I was wondering if it is possible to the Makefile first tries if docker-compose
exists, if not, uses docker compose
Is it possible?
CodePudding user response:
If you want it to be the most portable then you'd implement it in the shell, something like:
run:
test -n "$$(command -v docker-compose)" \
&& docker-compose up --build \
|| docker compose up --build
If you're willing to use make-specific features you can do something a bit fancier such as:
ifeq ($(shell command -v docker-compose;),)
COMPOSE := docker compose
else
COMPOSE := docker-compose
endif
run:
$(COMPOSE) up --build