From e1fa9996f7604f675307d4aa00c3c509000708b8 Mon Sep 17 00:00:00 2001
From: Vincent Massol <vincent@massol.net>
Date: Sat, 25 Feb 2017 13:22:20 +0100
Subject: [PATCH]  XDOCKER-11: Stop using Docker link feature
 (legacy/deprecated) * Use a better name for the property (thanks to Tianon)

---
 8/mysql-tomcat/Dockerfile                 | 4 ++--
 8/mysql-tomcat/docker-compose.yml         | 4 ++--
 8/mysql-tomcat/xwiki/docker-entrypoint.sh | 2 +-
 README.md                                 | 8 ++++----
 docker-compose-using.yml                  | 4 ++--
 template/Dockerfile                       | 4 ++--
 template/docker-compose.yml               | 4 ++--
 template/xwiki/docker-entrypoint.sh       | 2 +-
 8 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/8/mysql-tomcat/Dockerfile b/8/mysql-tomcat/Dockerfile
index f90f1e2..b840ce1 100644
--- a/8/mysql-tomcat/Dockerfile
+++ b/8/mysql-tomcat/Dockerfile
@@ -81,8 +81,8 @@ VOLUME /usr/local/xwiki
 #                configure xwiki's hibernate.cfg.xml file.
 # - DB_DATABASE: the name of the database to use. Default is "xwiki". This is used to configure xwiki's
 #                hibernate.cfg.xml file.
-# - DB_CONTAINER: The name of the docker container containing the database. Default is "db". This is used to
-#                 configure xwiki's hibernate.cfg.xml file.
+# - DB_HOST: The name of the host (or docker container) containing the database. Default is "db". This is used to
+#            configure xwiki's hibernate.cfg.xml file.
 
 # Example:
 #   docker run -it -e "DB_USER=xwiki" -e "DB_PASSWORD=xwiki" <imagename>
diff --git a/8/mysql-tomcat/docker-compose.yml b/8/mysql-tomcat/docker-compose.yml
index d29f367..6cf2f29 100644
--- a/8/mysql-tomcat/docker-compose.yml
+++ b/8/mysql-tomcat/docker-compose.yml
@@ -31,13 +31,13 @@ services:
     ports:
       - "8080:8080"
     # Default values defined in .env file.
-    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_CONTAINER variables are used in the hibernate.cfg.xml file.
+    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.
     environment:
       - XWIKI_VERSION=${XWIKI_VERSION}
       - DB_USER=${DB_USER}
       - DB_PASSWORD=${DB_PASSWORD}
       - DB_DATABASE=${DB_DATABASE}
-      - DB_CONTAINER=xwiki-mysql
+      - DB_HOST=xwiki-mysql
     # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)
     # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.
     volumes:
diff --git a/8/mysql-tomcat/xwiki/docker-entrypoint.sh b/8/mysql-tomcat/xwiki/docker-entrypoint.sh
index c918feb..753c104 100755
--- a/8/mysql-tomcat/xwiki/docker-entrypoint.sh
+++ b/8/mysql-tomcat/xwiki/docker-entrypoint.sh
@@ -49,7 +49,7 @@ function configure() {
   echo 'Configuring XWiki...'
   sed -i "s/replaceuser/${DB_USER:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
   sed -i "s/replacepassword/${DB_PASSWORD:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
-  sed -i "s/replacecontainer/${DB_CONTAINER:-db}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
+  sed -i "s/replacecontainer/${DB_HOST:-db}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
   sed -i "s/replacedatabase/${DB_DATABASE:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
 
   echo '  Using filesystem-based attachments...'
diff --git a/README.md b/README.md
index b2c6716..75e00f4 100644
--- a/README.md
+++ b/README.md
@@ -50,10 +50,10 @@ You should adapt the command line to use the passwords that you wish for the MyS
 Then run XWiki in another container by issuing the following command:
 
 ```console
-docker run --net=xwiki-nw --name xwiki -p 8080:8080 -v /my/own/xwiki:/usr/local/xwiki -e DB_USER=xwiki -e DB_PASSWORD=xwiki -e DB_DATABASE=xwiki -e DB_CONTAINER=mysql-xwiki xwiki:mysql-tomcat
+docker run --net=xwiki-nw --name xwiki -p 8080:8080 -v /my/own/xwiki:/usr/local/xwiki -e DB_USER=xwiki -e DB_PASSWORD=xwiki -e DB_DATABASE=xwiki -e DB_HOST=mysql-xwiki xwiki:mysql-tomcat
 ```
 
-Be careful to use the same MySQL username, password and database names that you've used on the first command to start the MySQL container. Also, please don't forget to add a `-e DB_CONTAINER=` environment variable with the name of the previously created MySQL container so that XWiki knows where its database is.
+Be careful to use the same MySQL username, password and database names that you've used on the first command to start the MySQL container. Also, please don't forget to add a `-e DB_HOST=` environment variable with the name of the previously created MySQL container so that XWiki knows where its database is.
 
 At this point, XWiki should start in interactive blocking mode, allowing you to see logs in the console. Should you wish to run it in "detached mode", just add a "-d" flag in the previous command.
 
@@ -89,7 +89,7 @@ services:
     environment:
       - DB_USER=xwiki
       - DB_PASSWORD=xwiki
-      - DB_CONTAINER=xwiki-mysql
+      - DB_HOST=xwiki-mysql
     volumes:
       - xwiki-data:/usr/local/xwiki
     networks:
@@ -135,7 +135,7 @@ The first time you create a container out of the xwiki image, a shell script (`/
 -	`DB_USER`: The user name used by XWiki to read/write to the DB.
 -	`DB_PASSWORD`: The user password used by XWiki to read/write to the DB.
 -	`DB_DATABASE`: The name of the XWiki database to use/create.
--	`DB_CONTAINER`: The name of the docker container used to run the DB.
+-	`DB_HOST`: The name of the host (or docker container) containing the database. Default is "db".
 
 ## Miscellaneous
 
diff --git a/docker-compose-using.yml b/docker-compose-using.yml
index 31c12d7..5ea883b 100644
--- a/docker-compose-using.yml
+++ b/docker-compose-using.yml
@@ -30,12 +30,12 @@ services:
       - db
     ports:
       - "8080:8080"
-    # The DB_USER/DB_PASSWORD/DB_CONTAINER variables are used in the hibernate.cfg.xml file.
+    # The DB_USER/DB_PASSWORD/DB_HOST variables are used in the hibernate.cfg.xml file.
     environment:
       - DB_USER=xwiki
       - DB_PASSWORD=xwiki
       - DB_DATABASE=xwiki
-      - DB_CONTAINER=xwiki-mysql
+      - DB_HOST=xwiki-mysql
     # Provide a name instead of an auto-generated id for the xwiki permanent directory configured in the Dockerfile,
     # to make it simpler to identify in 'docker volume ls'.
     volumes:
diff --git a/template/Dockerfile b/template/Dockerfile
index 91f09bb..826478f 100644
--- a/template/Dockerfile
+++ b/template/Dockerfile
@@ -85,8 +85,8 @@ VOLUME /usr/local/xwiki
 #                configure xwiki's hibernate.cfg.xml file.
 # - DB_DATABASE: the name of the database to use. Default is "xwiki". This is used to configure xwiki's
 #                hibernate.cfg.xml file.
-# - DB_CONTAINER: The name of the docker container containing the database. Default is "db". This is used to
-#                 configure xwiki's hibernate.cfg.xml file.
+# - DB_HOST: The name of the host (or docker container) containing the database. Default is "db". This is used to
+#            configure xwiki's hibernate.cfg.xml file.
 
 # Example:
 #   docker run -it -e "DB_USER=xwiki" -e "DB_PASSWORD=xwiki" <imagename>
diff --git a/template/docker-compose.yml b/template/docker-compose.yml
index a75b8c0..8a933f0 100644
--- a/template/docker-compose.yml
+++ b/template/docker-compose.yml
@@ -31,13 +31,13 @@ services:
     ports:
       - "8080:8080"
     # Default values defined in .env file.
-    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_CONTAINER variables are used in the hibernate.cfg.xml file.
+    # The DB_USER/DB_PASSWORD/DB_DATABASE/DB_HOST variables are used in the hibernate.cfg.xml file.
     environment:
       - XWIKI_VERSION=\${XWIKI_VERSION}
       - DB_USER=\${DB_USER}
       - DB_PASSWORD=\${DB_PASSWORD}
       - DB_DATABASE=\${DB_DATABASE}
-      - DB_CONTAINER=xwiki-mysql
+      - DB_HOST=xwiki-mysql
     # Provide a name instead of an auto-generated id for xwiki data (the permanent directory in included in it)
     # configured in the Dockerfile, to make it simpler to identify in 'docker volume ls'.
     volumes:
diff --git a/template/xwiki/docker-entrypoint.sh b/template/xwiki/docker-entrypoint.sh
index 25c7bc2..2eb18ce 100755
--- a/template/xwiki/docker-entrypoint.sh
+++ b/template/xwiki/docker-entrypoint.sh
@@ -49,7 +49,7 @@ function configure() {
   echo 'Configuring XWiki...'
   sed -i "s/replaceuser/\${DB_USER:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
   sed -i "s/replacepassword/\${DB_PASSWORD:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
-  sed -i "s/replacecontainer/\${DB_CONTAINER:-db}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
+  sed -i "s/replacecontainer/\${DB_HOST:-db}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
   sed -i "s/replacedatabase/\${DB_DATABASE:-xwiki}/g" /usr/local/tomcat/webapps/ROOT/WEB-INF/hibernate.cfg.xml
 
   echo '  Using filesystem-based attachments...'
-- 
GitLab