Public | Automated Build

Last pushed: 2 years ago
Short Description
Automated Mysql server container with backup cron task Build
Full Description

Mysql server container

This dockerfile is based on the mysql:latest Image

Weekly backup

It stores it's dumps beneath: /var/mysql-backup

It backups all databases separatly and all databases in one single dump file.

How to use this image

Start a mysql server instance

Starting a MySQL instance is simple:

docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -v /tmp/mysqlbackup:/var/mysql-backup -d kdelfour/mysql-docker:latest

… where some-mysql is the name you want to assign to your container, my-secret-pw is the password to be set for the MySQL root user and tag is the tag specifying the MySQL version you want. See the list above for relevant tags.

Connect to MySQL from an application in another Docker container

This image exposes the standard MySQL port (3306), so container linking makes the MySQL instance available to other application containers. Start your application container like this in order to link it to the MySQL container:

docker run --name some-app --link some-mysql:mysql-docker -d app-that-uses-mysql

Environment Variables

When you start the mysql image, you can adjust the configuration of the MySQL instance by passing one or more environment variables on the docker run command line. Do note that none of the variables below will have any effect if you start the container with a data directory that already contains a database: any pre-existing database will always be left untouched on container startup.

  • MYSQL_ROOT_PASSWORD : This variable is mandatory and specifies the password that will be set for the MySQL root superuser account. In the above example, it was set to my-secret-pw.
  • MYSQL_DATABASE : This variable is optional and allows you to specify the name of a database to be created on image startup. If a user/password was supplied (see below) then that user will be granted superuser access (corresponding to GRANT ALL) to this database.
  • MYSQL_USER, MYSQL_PASSWORD : These variables are optional, used in conjunction to create a new user and to set that user's password. This user will be granted superuser permissions (see above) for the database specified by the MYSQL_DATABASE variable. Both variables are required for a user to be created. Do note that there is no need to use this mechanism to create the root superuser, that user gets created by default with the password specified by the MYSQL_ROOT_PASSWORD variable.
  • MYSQL_ALLOW_EMPTY_PASSWORD : This is an optional variable. Set to yes to allow the container to be started with a blank password for the root user. NOTE: Setting this variable to yes is not recommended unless you really know what you are doing, since this will leave your MySQL instance completely unprotected, allowing anyone to gain complete superuser access.

User Feedback

Issues

If you have any problems with or questions about this image, please contact us through a GitHub issue.

Contributing

You are invited to contribute new features, fixes, or updates, large or small; we are always thrilled to receive pull requests, and do our best to process them as fast as we can.

Before you start to code, we recommend discussing your plans through a GitHub issue, especially for more ambitious contributions. This gives other contributors a chance to point you in the right direction, give you feedback on your design, and help you find out if someone else is working on the same thing.

Docker Pull Command
Owner
kdelfour
Source Repository