diff --git a/.gitattributes b/.gitattributes
index 770d78c04365ec13affb8567bf7e6e693b35484c..94239568fbd07cb92aeb733a2eb0524eaa49b730 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2345,7 +2345,7 @@ CMake/variants/variants.node521 -text
 CMake/variants/variants.phi -text
 CMake/variants/variants.sharkbay -text
 Docker/build.sh.example -text
-Docker/lofar-base/Dockerfile -text
+Docker/lofar-base/Dockerfile.tmpl -text
 Docker/lofar-base/bashrc -text
 Docker/lofar-base/chuser.sh -text
 Docker/lofar-base/subversion_servers -text
diff --git a/Docker/CMakeLists.txt b/Docker/CMakeLists.txt
index a8d53db4df8763336bbdc9fca045324d5f4666a2..316483f662fc0ffcaa89b2e55a3dcd27e282a8e9 100644
--- a/Docker/CMakeLists.txt
+++ b/Docker/CMakeLists.txt
@@ -15,6 +15,7 @@ lofar_find_package(Subversion REQUIRED)
 
 # Directories with Dockerfile.tmpl to parse
 set(DOCKER_TEMPLATE_DIRS
+  lofar-base
   lofar-pipeline
   lofar-outputproc)
 
diff --git a/Docker/lofar-base/Dockerfile b/Docker/lofar-base/Dockerfile.tmpl
similarity index 99%
rename from Docker/lofar-base/Dockerfile
rename to Docker/lofar-base/Dockerfile.tmpl
index e439b93b31799314003a30559f3a66ec80a0e364..6092e7d19cc103fd21b199d5ce140a2fcb3bced2 100644
--- a/Docker/lofar-base/Dockerfile
+++ b/Docker/lofar-base/Dockerfile.tmpl
@@ -28,7 +28,7 @@ ENV CFITSIO_VERSION=3370 \
 #
 # set-uid
 #
-ENV UID=1001
+ENV UID=${BUILD_UID}
 
 #
 # set-build-options
diff --git a/Docker/template.in b/Docker/template.in
index 37b5dea9e7a5a48ff65c4530e6979ea200c3f056..d134f8bdd08abfa28633c879308615687e8c4ee8 100755
--- a/Docker/template.in
+++ b/Docker/template.in
@@ -10,6 +10,7 @@
 #       ${BRANCH_URL}   = Full subversion URL for this branch
 #       ${REVISION}     = SVN revision number of this checkout
 #       ${NOW}          = now in UTC (format: 2016-01-01 10:11:12)
+#       ${BUILD_UID}    = uid of building user (=caller)
 #
 
 # ----- BRANCH_NAME = branches/LOFAR-Task1234 -----
@@ -50,8 +51,12 @@ export REVISION=`echo "$SVN_INFO" | perl -ne 'print "$1" if /Revision: +(.+)/;'`
 
 export NOW="`date -u +'%F %T'`"
 
+# ----- BUILD_UID = 1001 ----
+
+export BUILD_UID=`id -u`
+
 # ----- Process input -----
 
 # Insert our knowledge when processing stdin -> stdout
-envsubst '$BRANCH_NAME $BRANCH_URL $REVISION $NOW'
+envsubst '$BRANCH_NAME $BRANCH_URL $REVISION $NOW $BUILD_UID'