Skip to content

Instantly share code, notes, and snippets.



Last active Apr 20, 2017
What would you like to do?
Makefile with Docker support
DOCKER_IMAGE = your/image
.PHONY = target target2 docker
# Do something here
# Do something here
docker: ## Execute commands inside a Docker container
docker run --rm -it -v $$PWD:/app -w /app $(DOCKER_IMAGE) make $(filter-out docker, $(MAKECMDGOALS))
@printf "\033[36mExiting with non-zero status code to abort make. If you see this message your command successfully ran.\033[0m\n"
exit 1


$ make docker target # This will run `make target` inside the container
$ make docker target target2 # This will run `make target target2` inside the container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.