Makefile - no such file or directory error
There are a number of issues with your Makefile (beyond the question of whether a Makefile is the appropriate solution):
- conditional directives aren’t part of a recipe, so they mustn’t start with a tab;
- conditional directives are evaluated as the Makefile is read, so variables must be assigned previously and can’t be target-specific;
docker ps -a
returns information on all known containers, including non-running containers;- phony targets should be declared as such.
The following works:
result = $(shell docker ps -f name=myapp -q | wc -l)
start_docker_myapp:
ifeq ($(strip $(result)),1)
@echo true
else
@echo false
endif
.PHONY: start_docker_myapp