Skip to content
Maksym Zaporozhets edited this page Jun 15, 2023 · 2 revisions

Frequently Asked Questions

Can I import DB in the pre-built container?

Sure, you can!

Pre-built containers don't include volume to store DB data. So, running docker-compose stop or recreating the container/composition will destroy the DB data. This isn't an issue because developers use migration scripts, patches or write the code elsewhere instead of directly changing the DB structure. Test data is generated with Faker or other libraries. Thus, losing the DB data on container removal should be fine.

Your computer restart does not mean recreating the container, so you will not lose the data. Stopping the container will not destroy the data either because the container is not removed. You can start it again, and the data will be there.


How to get the root password from the pre-built DB? What if I need root access to edit privileges or do some other stuff?

Getting the root password from the pre-built DB container is impossible. You can only get the root password from the MySQL container logs on the first run for security reasons.

If you still need a root password or want it to be the same all the time (which is not recommended), then you can:

  1. Stop and remove the container, then rerun it and grep the password with the docker logs command. Use MySQL entrypoint (mysql_initdb dir) to import dump on startup or docker:mysql:import-db for manual import.
  2. Less recommended way is to remove the MYSQL_RANDOM_ROOT_PASSWORD/MARIADB_RANDOM_ROOT_PASSWORD variables from the MySQL container and the password via the MYSQL_ROOT_PASSWORD/MARIADB_ROOT_PASSWORD variables in the docker-compose.yaml file.

Remember that:

  1. MySQL password must not contain single quotes ('), double quotes ("), or backslash (\). Unfortunately, entrypoint scripts in different MySQL images use password environment variable differently. It is almost impossible to make it work with all of them. Thus, we decided to limit the password to a string without quotes. Other special characters are allowed.
  2. Remember that $ character in the MySQL password becomes $$ in the YAML files. Thus, $$$ becomes $$$$$$ in your docker-compose*.yaml files. This is specifics of the YAML format.

How to change the MySQL image registry? For example, we've moved the repository

All you need is to:

  1. Change the label com.default-value.docker.registry.target-image in the docker-compose.yaml file.
  2. Restart the composition.
  3. Use docker:mysql:import-db or docker:mysql:upload-to-aws command to upload the DB dump to S3. Use -b (--bucket) option to specify the new bucket name if needed.

This will generate and upload a new metadata file.

Remember to:

  • Notify your colleagues about this change. They should also restart their compositions for the labels to be updated.
  • Remove the old AWS bucket data if you've moved to another bucket as well.

What to do on dump upload failure?

Depending on the issue, you should probably:

  • Retry the upload in case there is a network issue. Only uploading a metadata file will trigger a pipeline. So, it's not a problem if a dump upload fails.
  • Contact a person responsible for setting up AWS access and buckets.

What to do on a pipeline failure? What to do if the image fails to build?

First, check that you can import the database dump and that the system is functional with this exact dump. Check the metadata file as well to ensure it's a valid JSON file, and it contains all the required fields. See docker:mysql:upload-to-aws documentation for more details about the metadata file structure.

Check pipeline logs and fix the issue. If you can't fix it, contact someone responsible for setting your CI/CD pipelines. There may be issues related to the registry access, runner configuration, resource limitations, etc.

Error messages are usually quite informative and it's easy to identify where the issue is and what causes it.

Clone this wiki locally