MySQL Container
A containerized MySQL database implementation that is suitable for development and test environments. The container entrypoint script will create the necessary database user, create a database, and grant the user all permissions on the created database.
Prerequisites
The mysql
container image must be built and available. For information on building container images, see Building Container Images.
Suitable Environment Types
The MySQL database implementation is suitable for development and test environments. The data is stored in the container and can disappear if the container is replaced. Database backup and restore tools are not supported.
Include in Development and QA Environments? | Include in Authoring Environments? | Include in Live Environments? |
---|---|---|
Yes | No | No |
Configuration
The sections below describe typical configurations.
Note about production sizing and tuning
The values shared in this document are suggestions that are known to work well in typical scenarios.
Resource allocation
Resource allocation can vary by usage and load. Below are typical values.
Resource | Non Production | Production Like (See Note) |
---|---|---|
Container Memory (MB) | 768 | N/A |
Container Cores | 0.25 | N/A |
Java Heap (MB) | N/A | N/A |
Scaling and replicas
This service is stateful and should not be scaled to maintain a consistent user experience.
Configuration | Non Production | Production Like (See Note) |
---|---|---|
Minumim Replicas | 1 | N/A |
Maximum Replicas | 1 | N/A |
Max Surge (%) | 25 | N/A |
Max Unavailable (%) | 25 | N/A |
Ports
Port | Non Production | Production | Purpose | Comment |
---|---|---|---|---|
3306 | Yes | N/A | JDBC port, allowing connectivity to the database. | This port should only be exposed internally, ideally only to the Commerce services that access the database. |
8180 | Yes | N/A | Health and liveness checks. | This port should only be exposed internally, ideally only to the container orchestrator. |
8888 | Optional | N/A | JMX | The container listens on this port when the ENABLE_JMX environment variable is set to true . This port should only be exposed internally to users and tools that require access to JMX data. |
1081 | Optional | N/A | Java debugger | The container will listen on this port when the ENABLE_DEBUG environment variable is set to true . This port should only be exposed internally, to developers who debug Java application code. This port is typically not open in production. |
Health, Liveness and Readiness
The MySQL command below is recommended for the container healthcheck.
mysql --defaults-file=/var/lib/mysql/healthcheck_cf -uhealthcheck -e "select User from mysql.user;"
Volumes
The MySQL container does not have specific support or recommendations for volumes.
Environment Variables
The MySQL service is configured using container environment variables. Some environment variables must be set and some are optional. The environment variables are read and consumed by the container entrypoint scripts. The supported environment variables for this service are shown in the following table.
Variable Name | Description | Required |
---|---|---|
MYSQL_ROOT_PASSWORD | The password to use for the MySQL database root user. | Yes |
MYSQL_DATABASE | The name of the database to create and use. | Yes |
MYSQL_USER | The user name for the MySQL database user that will be created. | Yes |
MYSQL_PASSWORD | THe password for the MySQL database user that will be created. | Yes |
important
The entrypoint scripts are and will remain the source of truth on the required environment variables. Review the container entrypoint scripts in your selected release to validate the required variables.