diff --git a/mapserver/Dockerfile b/mapserver/Dockerfile
index bdcaac29a6a0f3d00c294f56af3b896c9a68f807..994a50fb9d9bf4dc7e6b1f5edc1cece0c1d9863e 100644
--- a/mapserver/Dockerfile
+++ b/mapserver/Dockerfile
@@ -24,6 +24,7 @@ RUN mkdir -p /build_deps && cd /build_deps \
   && cmake .. -DWITH_PROTOBUFC=OFF -DWITH_POSTGIS=OFF \
   && make -j$(nproc) \
   && make install
+  && cd && rm -rf /build_deps
 
 # apache
 # http://www.inanzzz.com/index.php/post/rhsb/running-apache-server-as-foreground-on-ubuntu-with-dockerfile
@@ -87,7 +88,7 @@ RUN ln -s /usr/local/bin/mapserv /usr/lib/cgi-bin/mapserv && \
     chown ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /usr/lib/cgi-bin/* && \
     chown -h ${APACHE_RUN_USER}:${APACHE_RUN_GROUP} /usr/lib/cgi-bin/*
 
-RUN pip3 install jinja2
+RUN pip3 install jinja2 && rm -r /root/.cache/pip
 COPY render.py run.sh abi_l1b_template.map /work/
 COPY mapfiles/ /work/mapfiles/
 COPY html/ /var/www/html/