-
Notifications
You must be signed in to change notification settings - Fork 8
Generate MySQL metadata file
Maksym Zaporozhets edited this page Jun 19, 2023
·
2 revisions
Generate DB metadata file for a given container. This metadata can be used to reconstruct the same container. Metadata includes:
- Original vendor image name (
mysql
,bitnami/mariadb:10.3
, etc.). - All environment variables from the running container (thus, they include DB name, username, password, etc.).
- Mount destination of the
my.cnf
file. We need it because it differs between images. - Actually, a
my.cnf
file content. - Target image name to identify where to store the dump.
Supported MySQL images are:
mysql
mariadb
bitnami/mariadb
- Other images based on the above ones
Check for more information: Building MySQL images with DB: how it works
Example usage:
php bin/dockerizer docker:mysql:generate-metadata <container>
-
<container>
(first argument): MySQL container name. -
-t
(--target-image
, optional): Docker image name including registry domain (if needed) and excluding tags. If not specified, the command will ask for it interactively.
There are several ways to supply Docker image name:
- Explicitly pass is via the
--target-image
option - Declare it as a Docker container label
com.default-value.docker.registry.target-image
- Enter it manually when asked (interactive mode only)
We recommend adding the environment name as a target image suffix, for example:
my-docker-registry.com:5000/namespace/repository/database-dev
. E.g., add -dev
, -staging
, -prod
to make distinguishing DBs easier.
Inside a Docker container: MYSQL_USER
/MYSQL_PASSWORD
/MYSQL_DATABASE
or respective MariaDB environment variables.
Without them, it will be impossible to generate a new image with the proper credentials.
Example metadata file:
{
"vendor_image": "mysql:8.0.33",
"environment": [
"MYSQL_RANDOM_ROOT_PASSWORD=1",
"MYSQL_DATABASE=project_db",
"MYSQL_USER=project_user",
"MYSQL_PASSWORD=q1w2e3r4",
"affinity:container==somehashgoeshere",
"PATH=\/usr\/local\/sbin:\/usr\/local\/bin:\/usr\/sbin:\/usr\/bin:\/sbin:\/bin",
"GOSU_VERSION=1.16",
"MYSQL_MAJOR=8.0",
"MYSQL_VERSION=8.0.33-1.el8",
"MYSQL_SHELL_VERSION=8.0.33-1.el8"
],
"my_cnf_mount_destination": "\/etc\/mysql\/conf.d\/zzz-my.cnf",
"my_cnf": "[mysqld]\ndatadir=\/var\/lib\/mysql_datadir\n#datadir=\/var\/lib\/mysql_datadir\/\nwait_timeout=28800\nmax_allowed_packet=128M\ninnodb_log_file_size=128M\ninnodb_buffer_pool_size=1G\nlog_bin_trust_function_creators=1\n\n[mysql]\nauto-rehash",
"target_image": "registry.example.com\/namespace\/project\/database-prod"
}
- docker:mysql:connect
- docker:mysql:export-db
- docker:mysql:import-db
- docker:mysql:upload-to-aws
- docker:mysql:generate-metadata
- docker:mysql:reconstruct-db
- docker:mysql:test-metadata
- magento:setup
- magento:reinstall
- magento:test-module-install
- magento:test-templates
- magento:test-dockerfiles
- MacOS and Docker Desktop support
- Bash aliases
- Install Symfony with Dockerizer
- Running-apps-with-existing-Docker-compositions
- Limitations
- Building MySQL images with DB: how it works
- Configure AWS Lambda
- Gitlab pipeline to build images
- Managing AWS S3 access
- Using AWS credentials with Dockerizer
- Access management cheat-sheet
- FAQ