diff --git a/8/mysql-tomcat/Dockerfile b/8/mysql-tomcat/Dockerfile
index c72d1cc1adc6d103306866d5d1af8406604da3fe..73f05dc457e98f832897b7bc1e47a5a8b3ffa484 100644
--- a/8/mysql-tomcat/Dockerfile
+++ b/8/mysql-tomcat/Dockerfile
@@ -80,6 +80,11 @@ VOLUME /usr/local/xwiki
 #               xwiki's hibernate.cfg.xml file.
 # - MYSQL_PASSWORD: the password for the user configured for XWiki in the DB. Default is "xwiki". This is used to
 #                   configure xwiki's hibernate.cfg.xml file.
+# - MYSQL_DATABASE: the name of the database to use. Default is "xwiki". This is used to configure xwiki's
+#                   hibernate.cfg.xml file.
+# - DB_CONTAINER_NAME: The name of the docker container containing the database. Default is "db". This is used to
+#                      configure xwiki's hibernate.cfg.xml file.
+
 # Example:
 #   docker run -it -e "MYSQL_USER=xwiki" -e "MYSQL_PASSWORD=xwiki" <imagename>
 
@@ -88,6 +93,7 @@ VOLUME /usr/local/xwiki
 # container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply
 # with best practices defined at https://github.com/docker-library/official-images#consistency.
 ENV MYSQL_USER=xwiki \
-    MYSQL_PASSWORD=xwiki
+    MYSQL_PASSWORD=xwiki \
+    DB_CONTAINER_NAME
 ENTRYPOINT ["docker-entrypoint.sh"]
 CMD ["xwiki"]
diff --git a/9/mysql-tomcat/Dockerfile b/9/mysql-tomcat/Dockerfile
index 461c99435dfd0e877fdbc346d53a70e09fb56773..d64a49229d76f91a37f25b4a6fbad01a23d3d829 100644
--- a/9/mysql-tomcat/Dockerfile
+++ b/9/mysql-tomcat/Dockerfile
@@ -80,6 +80,11 @@ VOLUME /usr/local/xwiki
 #               xwiki's hibernate.cfg.xml file.
 # - MYSQL_PASSWORD: the password for the user configured for XWiki in the DB. Default is "xwiki". This is used to
 #                   configure xwiki's hibernate.cfg.xml file.
+# - MYSQL_DATABASE: the name of the database to use. Default is "xwiki". This is used to configure xwiki's
+#                   hibernate.cfg.xml file.
+# - DB_CONTAINER_NAME: The name of the docker container containing the database. Default is "db". This is used to
+#                      configure xwiki's hibernate.cfg.xml file.
+
 # Example:
 #   docker run -it -e "MYSQL_USER=xwiki" -e "MYSQL_PASSWORD=xwiki" <imagename>
 
@@ -88,6 +93,7 @@ VOLUME /usr/local/xwiki
 # container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply
 # with best practices defined at https://github.com/docker-library/official-images#consistency.
 ENV MYSQL_USER=xwiki \
-    MYSQL_PASSWORD=xwiki
+    MYSQL_PASSWORD=xwiki \
+    DB_CONTAINER_NAME
 ENTRYPOINT ["docker-entrypoint.sh"]
 CMD ["xwiki"]
diff --git a/template/Dockerfile b/template/Dockerfile
index ca41aac6ae06cbc74b64caeb89aaa995b16c679c..94eb0beaa15766f627c8bdf11cf256efa1c29520 100644
--- a/template/Dockerfile
+++ b/template/Dockerfile
@@ -80,6 +80,11 @@ VOLUME /usr/local/xwiki
 #               xwiki's hibernate.cfg.xml file.
 # - MYSQL_PASSWORD: the password for the user configured for XWiki in the DB. Default is "xwiki". This is used to
 #                   configure xwiki's hibernate.cfg.xml file.
+# - MYSQL_DATABASE: the name of the database to use. Default is "xwiki". This is used to configure xwiki's
+#                   hibernate.cfg.xml file.
+# - DB_CONTAINER_NAME: The name of the docker container containing the database. Default is "db". This is used to
+#                      configure xwiki's hibernate.cfg.xml file.
+
 # Example:
 #   docker run -it -e "MYSQL_USER=xwiki" -e "MYSQL_PASSWORD=xwiki" <imagename>
 
@@ -88,6 +93,7 @@ VOLUME /usr/local/xwiki
 # container executes and Tomcat will be started. If some other parameter is passed then it'll be executed to comply
 # with best practices defined at https://github.com/docker-library/official-images#consistency.
 ENV MYSQL_USER=xwiki \
-    MYSQL_PASSWORD=xwiki
+    MYSQL_PASSWORD=xwiki \
+    DB_CONTAINER_NAME
 ENTRYPOINT ["docker-entrypoint.sh"]
 CMD ["xwiki"]