diff --git a/Makefile.include b/Makefile.include
index 2c1dd40102a3786607ea15d61afb4a51225fbd58..d4425a46c6a119f71572629d51630fc220ad4dac 100644
--- a/Makefile.include
+++ b/Makefile.include
@@ -14,6 +14,7 @@ RIOTPKG        ?= $(RIOTBASE)/pkg
 RIOTTOOLS      ?= $(RIOTBASE)/dist/tools
 RIOTPROJECT    ?= $(shell git rev-parse --show-toplevel 2>/dev/null || pwd)
 GITCACHE       ?= $(RIOTTOOLS)/git/git-cache
+GIT_CACHE_DIR  ?= $(HOME)/.gitcache
 APPDIR         ?= $(CURDIR)
 BINDIRBASE     ?= $(APPDIR)/bin
 BINDIR         ?= $(BINDIRBASE)/$(BOARD)
diff --git a/makefiles/docker.inc.mk b/makefiles/docker.inc.mk
index 372955c2eb49cca3218b3cd73987de8af29b6053..1fd8766a096891e3731f62e162e50d6f13fdc9ca 100644
--- a/makefiles/docker.inc.mk
+++ b/makefiles/docker.inc.mk
@@ -83,6 +83,12 @@ DOCKER_OVERRIDE_CMDLINE := $(strip $(DOCKER_OVERRIDE_CMDLINE))
 # Overwrite if you want to use `docker` with sudo
 DOCKER ?= docker
 
+# Mounted volumes and exported environment variables
+
+# Add GIT_CACHE_DIR if the directory exists
+DOCKER_VOLUMES_AND_ENV += $(if $(wildcard $(GIT_CACHE_DIR)),-v $(GIT_CACHE_DIR):$(DOCKER_BUILD_ROOT)/gitcache)
+DOCKER_VOLUMES_AND_ENV += $(if $(wildcard $(GIT_CACHE_DIR)),-e GIT_CACHE_DIR=$(DOCKER_BUILD_ROOT)/gitcache)
+
 # 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
@@ -105,6 +111,7 @@ DOCKER ?= docker
 	    -e 'RIOTBOARD=$(DOCKER_BUILD_ROOT)/riotboard' \
 	    -e 'RIOTMAKE=$(DOCKER_BUILD_ROOT)/riotmake' \
 	    -e 'RIOTPROJECT=$(DOCKER_BUILD_ROOT)/riotproject' \
+	    $(DOCKER_VOLUMES_AND_ENV) \
 	    $(DOCKER_ENVIRONMENT_CMDLINE) \
 	    -w '$(DOCKER_BUILD_ROOT)/riotproject/$(BUILDRELPATH)' \
 	    '$(DOCKER_IMAGE)' make $(DOCKER_MAKECMDGOALS) $(DOCKER_OVERRIDE_CMDLINE)
diff --git a/makefiles/vars.inc.mk b/makefiles/vars.inc.mk
index 3492bffbf0b09516691cfb179de9c75bc0ebd7d2..0dee7327642c3beeeb7510f1d8d6b4436b970fca 100644
--- a/makefiles/vars.inc.mk
+++ b/makefiles/vars.inc.mk
@@ -67,6 +67,7 @@ export UNDEF                 # Object files that the linker must include in the
 export WERROR                # Treat all compiler warnings as errors if set to 1 (see -Werror flag in GCC manual)
 
 export GITCACHE              # path to git-cache executable
+export GIT_CACHE_DIR         # path to git-cache cache directory
 export FLASHER               # The command to call on "make flash".
 export FFLAGS                # The parameters to supply to FLASHER.
 export FLASH_ADDR            # Define an offset to flash code into ROM memory.