Skip to content
This repository has been archived by the owner on Nov 29, 2020. It is now read-only.

Mysql config file ignored #12

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
data-mysql
8 changes: 6 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
FROM ubuntu:trusty
FROM ubuntu:12.04
MAINTAINER Fernando Mayo <fernando@tutum.co>, Feng Honglin <hfeng@tutum.co>
ENV http_proxy http://00026898:Stefan1@165.222.184.232:8080
ENV https_proxy http://00026898:Stefan1@165.222.184.232:8080



# Install packages
RUN apt-get update
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install supervisor mysql-server pwgen

# Remove pre-installed database
RUN rm -rf /var/lib/mysql
RUN rm -rf /var/lib/mysql/*

# Add MySQL configuration
ADD my.cnf /etc/mysql/conf.d/my.cnf
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ tutum-docker-mysql
Base docker image to run a MySQL database server


MySQL version
-------------

`master` branch maintains MySQL from Ubuntu trusty official source. If you want to get different version of MySQL, please checkout `5.5` branch and `5.6` branch.

Usage
-----

Expand Down Expand Up @@ -79,7 +84,7 @@ Mounting the database file volume from other containers
Another way to persist the database data is to store database files in another container.
To do so, first create a container that holds database files:

docker run -d -v /var/lib/mysql --name db_vol tutum/ubuntu-trusty
docker run -d -v /var/lib/mysql --name db_vol -p 22:22 tutum/ubuntu-trusty

This will create a new ssh-enabled container and use its folder `/var/lib/mysql` to store MySQL database files.
You can specify any name of the container by using `--name` option, which will be used in next step.
Expand Down
105 changes: 104 additions & 1 deletion my.cnf
Original file line number Diff line number Diff line change
@@ -1,2 +1,105 @@
#
# The MySQL database server configuration file.
#
# You can copy this to one of:
# - "/etc/mysql/my.cnf" to set global options,
# - "~/.my.cnf" to set user-specific options.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

# This was formally known as [safe_mysqld]. Both versions are currently parsed.
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0

[mysqld]
bind-address=0.0.0.0
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp

lc-messages-dir = /usr/share/mysql
skip-external-locking
max_allowed_packet = 32M
key_buffer_size = 96M
query_cache_size= 72M

# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 6
table_cache = 1024
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 0.0.0.0

#
# * Query Cache Configuration
#
query_cache_limit = 1M
#
# Error log - should be very few entries.
#
log_error = /var/log/mysql/error.log

#
# Here you can see queries with especially long duration
#log_slow_queries = /var/log/mysql/mysql-slow.log
#long_query_time = 2
#log-queries-not-using-indexes
#
expire_logs_days = 10
max_binlog_size = 100M
#
# * InnoDB
#
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
# Read the manual for more InnoDB related options. There are many!

innodb_buffer_pool_size = 1024M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 256M
innodb_log_buffer_size = 64M

innodb_file_per_table = 1
innodb_flush_log_at_trx_commit = 2
innodb_support_xa = 0
innodb_flush_method= O_DIRECT

[mysqldump]
quick
quote-names
max_allowed_packet = 16M

[mysql]
#no-auto-rehash # faster start of mysql but no tab completition

[isamchk]
key_buffer = 16M

#
# * IMPORTANT: Additional settings that can override those from this file!
# The files must end with '.cnf', otherwise they'll be ignored.
#

10 changes: 10 additions & 0 deletions run-server.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

# rm -rf data-mysql
mkdir -p data-mysql

# as daemon
docker run --name mysql -d -p 3306:3306 -v $(pwd)/data-mysql:/var/lib/mysql -e MYSQL_PASS="samba" tutum/mysql

# interactive
#docker run -i -t -p 3306:3306 -v $(pwd)/data-mysql:/var/lib/mysql -e MYSQL_PASS="samba" tutum/mysql bash
5 changes: 2 additions & 3 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
#!/bin/bash

VOLUME_HOME="/var/lib/mysql"
HOME=/etc/mysql/conf.d/

if [[ ! -d $VOLUME_HOME/mysql ]]; then
echo "=> An empty or uninitialized MySQL volume is detected in $VOLUME_HOME"
echo "=> Installing MySQL ..."
mkdir -p $VOLUME_HOME
chown mysql:mysql -R $VOLUME_HOME
mysql_install_db > /dev/null 2>&1
echo "=> Done!"
/create_mysql_admin_user.sh
/create_mysql_admin_user.sh
else
echo "=> Using an existing volume of MySQL"
fi
Expand Down