Configure central database access to the Utility Docker container
Centralized configuration of database access information allows utilities to run without having to directly specify login and other information. Using this feature, the Utility Docker container will have the information available after being created.
Task info
After database access information is centralized using this feature, every Utility Docker container created will have the database information built into it. The startup process involves:
- Collecting the database access information.
- Placing the database access information in the following file:
/opt/WebSphere/CommerceServer90/xml/config/alldbconnector.xml
After this startup process is complete, the database access information will be available to each utility that uses that file. There can be multiple such database profiles created in this way. Each profile consists of a JDBC URL, a user and a password, and is associated with a database type (DB2 or Oracle). There is always a profile called "default". Here is an example of how a database profile is defined in alldbconnector.xml:
<override identifier= "default" enabled="yes"> <jdbcurl value="jdbc:db2://vm32.mycompany.com:50000/mall" enabled="yes"/> <property name="user" value="wcs"/> <property name="password" value="wcs1"/> </override>This database information must be available to the Utility Docker container at the time of its creation. There are three ways that the information can be made available: via Vault; through the config.properties file; or as environment variables within the Docker image itself. The configUtility.sh process will try to search for the variables in the following sequence:
- First, it checks for the environment variables which signal that the container is setup with Vault: VAULT_TOKEN, VAULT_URL, TENANT, ENVIRONMENT, ENVTYPE. If these are present, the database access information will be retrieved from Vault. Note that the process will not use other methods for obtaining the database access information. Therefore, if one database profile is in Vault then all need to be in Vault.
- If the Vault environment variables are not available, the process will attempt to retrieve the database access information from environment variables.
It then writes the data to allDBConnector.xml.
Procedure
Adding database login variables to the Vault
- Open a command line window in the Utility Docker container.
- Use curl to add the variables for the default database profile: dbHost, dbPort, dbName, dbType, dbUser, dbPass. The following example shows the addition of the 'mall' dbName.
curl -X POST -H "X-Vault-Token:7f47efbb-b162-619b-0ced-448079d91b77" -d '{"value":"mall"}' http://myhostname.com:8200/v1/MyCompany/Non-production/auth/dbName
Adding profile information as environment variables
- Instead of adding the variables to the Vault as in Steps 1 and 2, you may choose to add them as environment variables instead.
- Open the /SETUP/ext-config/config.properties file for editing.
- Add the following variables to the file: DBHOST, DBPORT, DBNAME, DBTYPE, DBUSER, DBPASS.
- Save and exit the file.
What to do next
There are numerous parameters that we can use when starting a new Docker container. For more information, see Docker container start up logic for 9.0.0.2 or later.
Related tasks
Configure database connections in Docker images
Related reference
runSQL utility