diff --git a/docker-compose/jupyter/Dockerfile b/docker-compose/jupyter/Dockerfile
index da3f1da1c5bc09fa4a1861377d2533faca70535a..62fb7395184b9bc9f4540c8ad68acabc5dc26713 100644
--- a/docker-compose/jupyter/Dockerfile
+++ b/docker-compose/jupyter/Dockerfile
@@ -1,6 +1,10 @@
 ARG VERSION=latest
 FROM nexus.engageska-portugal.pt/ska-docker/tango-itango:${VERSION}
 
+# UID if the user that this container will run under. This is needed to give directories
+# that are needed for temporary storage the proper owner and access rights.
+ARG CONTAINER_EXECUTION_UID=1000
+
 RUN sudo pip3 install jupyter
 RUN sudo pip3 install ipykernel
 RUN sudo pip3 install jupyter_bokeh
@@ -13,7 +17,6 @@ RUN sudo jupyter nbextension enable jupyter_bokeh --py --sys-prefix
 
 # Install profiles for ipython & jupyter
 COPY ipython-profiles /opt/ipython-profiles/
-RUN sudo chmod a+rw -R /opt/ipython-profiles
 COPY jupyter-kernels /usr/local/share/jupyter/kernels/
 
 # Install patched jupyter executable
@@ -28,5 +31,6 @@ RUN sudo chmod +x /usr/bin/tini
 
 # Make sure Jupyter can write to the home directory
 ENV HOME=/home/user
-RUN sudo mkdir -p $HOME
-RUN sudo chmod a+rwx $HOME
+RUN sudo mkdir -p ${HOME}
+RUN sudo chown ${CONTAINER_EXECUTION_UID} -R ${HOME}
+RUN sudo chown ${CONTAINER_EXECUTION_UID} -R /opt/ipython-profiles