From e5c49aa4861e9814735bfefba64212dfd297d27f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Harter?= <gaetan.harter@fu-berlin.de> Date: Wed, 25 Jul 2018 17:29:04 +0200 Subject: [PATCH] makefiles/docker.inc.mk: allow overwriting 'docker' command Not all users register their user in the docker group and should not run the whole make process as root to use docker. They can now overwrite DOCKER with `DOCKER="sudo docker"`. Creating files as a user is correctly handled as `id -u` is still run as the original user. --- makefiles/docker.inc.mk | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/makefiles/docker.inc.mk b/makefiles/docker.inc.mk index aebb2057e7..488c901b93 100644 --- a/makefiles/docker.inc.mk +++ b/makefiles/docker.inc.mk @@ -79,6 +79,9 @@ DOCKER_OVERRIDE_CMDLINE := $(foreach varname,$(DOCKER_ENV_VARS), \ )) DOCKER_OVERRIDE_CMDLINE := $(strip $(DOCKER_OVERRIDE_CMDLINE)) +# Overwrite if you want to use `docker` with sudo +DOCKER ?= docker + # This will execute `make $(DOCKER_MAKECMDGOALS)` inside a Docker container. # We do not push the regular $(MAKECMDGOALS) to the container's make command in # order to only perform building inside the container and defer executing any @@ -88,7 +91,7 @@ DOCKER_OVERRIDE_CMDLINE := $(strip $(DOCKER_OVERRIDE_CMDLINE)) # hardware which may not be reachable from inside the container. ..in-docker-container: @$(COLOR_ECHO) '$(COLOR_GREEN)Launching build container using image "$(DOCKER_IMAGE)".$(COLOR_RESET)' - docker run $(DOCKER_FLAGS) -t -u "$$(id -u)" \ + $(DOCKER) run $(DOCKER_FLAGS) -t -u "$$(id -u)" \ -v '$(RIOTBASE):$(DOCKER_BUILD_ROOT)/riotbase' \ -v '$(RIOTCPU):$(DOCKER_BUILD_ROOT)/riotcpu' \ -v '$(RIOTBOARD):$(DOCKER_BUILD_ROOT)/riotboard' \ -- GitLab