diff --git a/xwiki-mysql-tomcat/Dockerfile b/xwiki-mysql-tomcat/Dockerfile
index 6a979d2ef77d2ae54171b575b263946bbaccc46a..c1468a19125de917f6b87b5a7eb5f598f5e814c8 100644
--- a/xwiki-mysql-tomcat/Dockerfile
+++ b/xwiki-mysql-tomcat/Dockerfile
@@ -70,7 +70,7 @@ RUN sed "s/<id>org.xwiki.enterprise:xwiki-enterprise-web/<id>org.xwiki.enterpris
 COPY xwiki/xwiki-config-replace.sh /usr/local/bin/xwiki-config-replace.sh
 COPY xwiki/xwiki-set-cfg /usr/local/bin/xwiki-set-cfg
 COPY xwiki/xwiki-set-properties /usr/local/bin/xwiki-set-properties
-COPY xwiki/start_xwiki.sh /usr/local/bin/start_xwiki.sh
+COPY xwiki/docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
 
 # Make the XWiki directory (the permanent directory is included in it) persist on the host (so that it's not recreated
 # across runs)
@@ -91,13 +91,10 @@ EXPOSE 8080
 #   docker run -it -e "MYSQL_USER=xwiki" -e "MYSQL_PASSWORD=xwiki" <imagename>
 
 # Starts XWiki by starting Tomcat. All options passed to "docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]"
-# are also passed to start_xwiki.sh. However at the moment start_xwiki.sh doesn't support any parameters and all
-# configurations are done through environment variable overrides (see above).
+# are also passed to docker-entrypoint.sh. If "xwiki" is passed then XWiki will be configured the first time the
+# 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
-ENTRYPOINT ["start_xwiki.sh"]
-
-# When no options are passed on the "docker run" command line we display a message explaining what environment
-# variables can be overridden.
-# Note: This is not implemented yet and FTM --info does nothing.
-CMD ["--info"]
+ENTRYPOINT ["docker-entrypoint.sh"]
+CMD ["xwiki"]
diff --git a/xwiki-mysql-tomcat/xwiki/docker-entrypoint.sh b/xwiki-mysql-tomcat/xwiki/docker-entrypoint.sh
new file mode 100755
index 0000000000000000000000000000000000000000..d8ba2103afd54a6d3ada0923ff808dbf029a14a0
--- /dev/null
+++ b/xwiki-mysql-tomcat/xwiki/docker-entrypoint.sh
@@ -0,0 +1,63 @@
+#!/bin/bash
+# ---------------------------------------------------------------------------
+# See the NOTICE file distributed with this work for additional
+# information regarding copyright ownership.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+# ---------------------------------------------------------------------------
+
+set -e
+
+function first_start() {
+  configure
+  touch /usr/local/xwiki/.first_start_completed
+}
+
+function configure() {
+  echo 'Configuring XWiki...'
+  sed -i "s/replacemysqluser/${MYSQL_USERNAME:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
+  sed -i "s/replacemysqlpassword/${MYSQL_PASSWORD:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
+
+  echo '  Using filesystem-based attachments...'
+  xwiki-set-cfg 'xwiki.store.attachment.hint' 'file'
+  xwiki-set-cfg 'xwiki.store.attachment.versioning.hint' 'file'
+  xwiki-set-cfg 'xwiki.store.attachment.recyclebin.hint' 'file'
+  echo '  Generating authentication validation and encryption keys...'
+  xwiki-set-cfg 'xwiki.authentication.validationKey' "$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
+  xwiki-set-cfg 'xwiki.authentication.encryptionKey' "$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
+
+  echo '  Setting permanent directory...'
+  xwiki-set-properties 'environment.permanentDirectory' '/usr/local/xwiki/data'
+  echo '  Configure libreoffice...'
+  xwiki-set-properties 'openoffice.autoStart' 'true'
+}
+
+# This if will check if the first argument is a flag but only works if all arguments require a hyphenated flag
+# -v; -SL; -f arg; etc will work, but not arg1 arg2
+if [ "${1:0:1}" = '-' ]; then
+    set -- xwiki "$@"
+fi
+
+# Check for the expected command
+if [ "$1" = 'xwiki' ]; then
+  if [[ ! -f /usr/local/xwiki/.first_start_completed ]]; then
+    first_start
+  fi
+  /usr/local/tomcat/bin/catalina.sh run
+fi
+
+# Else default to run whatever the user wanted like "bash"
+exec "$@"
diff --git a/xwiki-mysql-tomcat/xwiki/start_xwiki.sh b/xwiki-mysql-tomcat/xwiki/start_xwiki.sh
deleted file mode 100755
index f4aa9bac95a25cb7d13c4d1f16c301f035eeeb4c..0000000000000000000000000000000000000000
--- a/xwiki-mysql-tomcat/xwiki/start_xwiki.sh
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-function first_start() {
-  configure
-  touch /usr/local/xwiki/.first_start_completed
-}
-
-function configure() {
-  echo 'Configuring XWiki...'
-  sed -i "s/replacemysqluser/${MYSQL_USERNAME:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
-  sed -i "s/replacemysqlpassword/${MYSQL_PASSWORD:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
-
-  echo '  Using filesystem-based attachments...'
-  xwiki-set-cfg 'xwiki.store.attachment.hint' 'file'
-  xwiki-set-cfg 'xwiki.store.attachment.versioning.hint' 'file'
-  xwiki-set-cfg 'xwiki.store.attachment.recyclebin.hint' 'file'
-  echo '  Generating authentication validation and encryption keys...'
-  xwiki-set-cfg 'xwiki.authentication.validationKey' "$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
-  xwiki-set-cfg 'xwiki.authentication.encryptionKey' "$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)"
-
-  echo '  Setting permanent directory...'
-  xwiki-set-properties 'environment.permanentDirectory' '/usr/local/xwiki/data'
-  echo '  Configure libreoffice...'
-  xwiki-set-properties 'openoffice.autoStart' 'true'
-}
-
-if [[ ! -f /usr/local/xwiki/.first_start_completed ]]; then
-  first_start
-fi
-
-/usr/local/tomcat/bin/catalina.sh run
\ No newline at end of file
diff --git a/xwiki-mysql-tomcat/xwiki/xwiki-config-replace.sh b/xwiki-mysql-tomcat/xwiki/xwiki-config-replace.sh
index 963af5df6c5fd9bc6e27ddfe65ed599b0d610332..82b62d0c5717aaf6cbbe6299d7a845601bd3d630 100755
--- a/xwiki-mysql-tomcat/xwiki/xwiki-config-replace.sh
+++ b/xwiki-mysql-tomcat/xwiki/xwiki-config-replace.sh
@@ -1,4 +1,23 @@
 #!/bin/bash
+# ---------------------------------------------------------------------------
+# See the NOTICE file distributed with this work for additional
+# information regarding copyright ownership.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+# ---------------------------------------------------------------------------
 
 # $1 - the path to xwiki.[cfg|properties]
 # $2 - the setting/property to set
diff --git a/xwiki-mysql-tomcat/xwiki/xwiki-set-cfg b/xwiki-mysql-tomcat/xwiki/xwiki-set-cfg
index 29c7411f97f80ca78e6cba1e95e9acc5046218d2..a623a797ce1995274521ac889e67a806162c2663 100755
--- a/xwiki-mysql-tomcat/xwiki/xwiki-set-cfg
+++ b/xwiki-mysql-tomcat/xwiki/xwiki-set-cfg
@@ -1,4 +1,23 @@
 #!/bin/bash
+# ---------------------------------------------------------------------------
+# See the NOTICE file distributed with this work for additional
+# information regarding copyright ownership.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+# ---------------------------------------------------------------------------
 
 # $1 - the setting/property to set
 # $2 - the new value
diff --git a/xwiki-mysql-tomcat/xwiki/xwiki-set-properties b/xwiki-mysql-tomcat/xwiki/xwiki-set-properties
index 90fb72d10bb79d04f564e73f5f7f11edd20ded02..4ead840846c4d648d4131195d655c041cafce3dd 100755
--- a/xwiki-mysql-tomcat/xwiki/xwiki-set-properties
+++ b/xwiki-mysql-tomcat/xwiki/xwiki-set-properties
@@ -1,4 +1,23 @@
 #!/bin/bash
+# ---------------------------------------------------------------------------
+# See the NOTICE file distributed with this work for additional
+# information regarding copyright ownership.
+#
+# This is free software; you can redistribute it and/or modify it
+# under the terms of the GNU Lesser General Public License as
+# published by the Free Software Foundation; either version 2.1 of
+# the License, or (at your option) any later version.
+#
+# This software is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this software; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+# 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+# ---------------------------------------------------------------------------
 
 # $1 - the setting/property to set
 # $2 - the new value