While I’m working with docker I use a handful of commands: build this project, run it with certain environment variables, remove the image/container. First I tried writing shell scripts to prevent me for typing this commands over and over. But the disadvantages are clear: I had quickly a bunch of scripts and I could not commit this scripts to our VCS because all this scripts were to much coupled to my setup. After a while thinking I came up with this solution: I have a base Makefile that includes a configuration file which is ignored by the VCS. This way everyone profit from the handy make commands like make build, make run etc. but all my colleagues can configure their own setting.

Here the Makefile template (thanks to @blang for the initial template)

include env_make
NS = your docker namespace
VERSION ?= latest

REPO = your docker repo name
NAME = name of the image
INSTANCE = default

.PHONY: build push shell run start stop rm release

	docker build -t $(NS)/$(REPO):$(VERSION) .

	docker push $(NS)/$(REPO):$(VERSION)

	docker run --rm --name $(NAME)-$(INSTANCE) -i -t $(PORTS) $(VOLUMES) $(ENV) $(NS)/$(REPO):$(VERSION) /bin/bash

	docker run --rm --name $(NAME)-$(INSTANCE) $(PORTS) $(VOLUMES) $(ENV) $(NS)/$(REPO):$(VERSION)

	docker run -d --name $(NAME)-$(INSTANCE) $(PORTS) $(VOLUMES) $(ENV) $(NS)/$(REPO):$(VERSION)

	docker stop $(NAME)-$(INSTANCE)

	docker rm $(NAME)-$(INSTANCE)

release: build
	make push -e VERSION=$(VERSION)

default: build

and don’t forget to place an env_make file next to your Makefile that is ignored by the VCS:

PORTS = -p 8080:80

VOLUMES = -v /var/log/docker:/var/log

ENV = \