Skip to content

Instantly share code, notes, and snippets.

@vitaly
Created May 27, 2015 15:32
Show Gist options
  • Save vitaly/9351ad175dac36cc283e to your computer and use it in GitHub Desktop.
Save vitaly/9351ad175dac36cc283e to your computer and use it in GitHub Desktop.
generic Make build target for building docker images
# generic build rule
docker/build/%: docker/recipes/%/Dockerfile .dockerignore
@echo
@echo
@echo =================================== Building $@
@echo
@echo
docker build --rm -t $* -f "$<" .
docker inspect --format="{{.Id}}" $* > $@
@echo
@echo =================================== DONE: $@ `cat "$@"`
@echo
clean:
rm -v docker/build/*
.PHONY: clean
gc:
@docker ps --filter "status=exited" | grep -v data | grep -v ^CONTAINER | awk '{print $$1}' | xargs docker rm
.PHONY: gc
gci:
docker images -q --filter "dangling=true" | xargs docker rmi
.PHONY: gci%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment