Skip to content

Commit 57ca8b9

Browse files
committed
Merge pull request #4 from sparklyballs/master
Switch to 10.1 repository and other changes.
2 parents 5785d5c + 943d303 commit 57ca8b9

File tree

7 files changed

+189
-47
lines changed

7 files changed

+189
-47
lines changed

Dockerfile

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ ENV MYSQL_DIR="/config"
99
ENV DATADIR=$MYSQL_DIR/databases
1010

1111
# set the repo version for mariadb choose between 5.5 or 10.0
12-
ENV REPO_VER 10.0
12+
ENV REPO_VER 10.1
1313

1414
# update apt and install packages
1515
RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db && \
16-
add-apt-repository "deb http://mirrors.coreix.net/mariadb/repo/$REPO_VER/ubuntu trusty main" && \
16+
echo "deb [arch=amd64,i386] http://lon1.mirrors.digitalocean.com/mariadb/repo/${REPO_VER}/ubuntu trusty main" >> /etc/apt/sources.list.d/mariadb.list && \
1717
apt-get update && \
1818
apt-get install \
1919
$INSTALL_LIST -qy && \
@@ -23,21 +23,14 @@ apt-get clean -y && \
2323
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /var/lib/mysql && \
2424
mkdir -p /var/lib/mysql
2525

26-
# configure mariadb
27-
RUN sed -i 's/key_buffer\b/key_buffer_size/g' /etc/mysql/my.cnf && \
28-
sed -ri 's/^(bind-address|skip-networking)/;\1/' /etc/mysql/my.cnf && \
29-
sed -i s#/var/log/mysql#/config/log/mysql#g /etc/mysql/my.cnf && \
30-
sed -i -e 's/\(user.*=\).*/\1 abc/g' /etc/mysql/my.cnf && \
31-
sed -i -e "s#\(datadir.*=\).*#\1 $DATADIR#g" /etc/mysql/my.cnf && \
32-
sed -i "s/user='mysql'/user='abc'/g" /usr/bin/mysqld_safe && \
33-
cp /etc/mysql/my.cnf /defaults/my.cnf
34-
3526
#Adding Custom files
36-
ADD init/ /etc/my_init.d/
37-
ADD services/ /etc/service/
27+
COPY defaults/ /defaults/
28+
COPY init/ /etc/my_init.d/
29+
COPY services/ /etc/service/
3830
RUN chmod -v +x /etc/service/*/run /etc/my_init.d/*.sh
3931

4032
# set volumes and ports
4133
VOLUME /config
4234
EXPOSE 3306
4335

36+

README.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
![https://linuxserver.io](https://www.linuxserver.io/wp-content/uploads/2015/06/linuxserver_medium.png)
22

3-
The [LinuxServer.io](https://linuxserver.io) team brings you another quality container release featuring easy user mapping and community support. Be sure to checkout our [forums](https://forum.linuxserver.io) or for real-time support our [IRC](https://www.linuxserver.io/index.php/irc/) on freenode at `#linuxserver.io`.
3+
The [LinuxServer.io](https://linuxserver.io) team brings you another container release featuring easy user mapping and community support. Find us for support at:
4+
* [forum.linuxserver.io](https://forum.linuxserver.io)
5+
* [IRC](https://www.linuxserver.io/index.php/irc/) on freenode at `#linuxserver.io`
6+
* [Podcast](https://www.linuxserver.io/index.php/category/podcast/) covers everything to do with getting the most from your Linux Server plus a focus on all things Docker and containerisation!
47

58
# linuxserver/mariadb
69

7-
10+
![](https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/mariadb-git.png)
811

912
## Usage
1013

@@ -27,31 +30,38 @@ linuxserver/mariadb
2730
* `-e PGID` for GroupID - see below for explanation
2831
* `-e PUID` for UserID - see below for explanation
2932

30-
It is based on phusion-baseimage with ssh removed, for shell access whilst the container is running do `docker exec -it mariadb /bin/bash`.
31-
3233
### User / Group Identifiers
3334

34-
**TL;DR** - The `PGID` and `PUID` values set the user / group you'd like your container to 'run as' to the host OS. This can be a user you've created or even root (not recommended).
35+
Sometimes when using data volumes (`-v` flags) permissions issues can arise between the host OS and the container. We avoid this issue by allowing you to specify the user `PUID` and group `PGID`. Ensure the data volume directory on the host is owned by the same user you specify and it will "just work" ™.
36+
37+
In this instance `PUID=1001` and `PGID=1001`. To find yours use `id user` as below:
3538

36-
Part of what makes our containers work so well is by allowing you to specify your own `PUID` and `PGID`. This avoids nasty permissions errors with relation to data volumes (`-v` flags). When an application is installed on the host OS it is normally added to the common group called users, Docker apps due to the nature of the technology can't be added to this group. So we added this feature to let you easily choose when running your containers.
39+
```
40+
$ id <dockeruser>
41+
uid=1001(dockeruser) gid=1001(dockergroup) groups=1001(dockergroup)
42+
```
3743

3844
## Setting up the application
3945

4046
If you didn't set a password during installation, (see logs for warning) use mysqladmin -u root password <PASSWORD> to set one at the docker prompt... NOTE changing the MYSQL_ROOT_PASSWORD variable after the container has set up the initial databases has no effect. It is also advisable to edit the run command or template/webui after setup and remove reference to this variable.
4147

42-
Find my.cnf in /config, the databases in /config/databases and the log in /config/log/myqsl
48+
Find custom.cnf in /config for config changes (restart container for them to take effect)
49+
, the databases in /config/databases and the log in /config/log/myqsl
4350

4451
The container also has mysqltuner included which can either be run from within the container by exec'ing in or externally by issuing `docker exec -it mariadb mysqltuner`. It will prompt for credentials if you have set a password for root user.
4552

4653

4754

48-
## Logs
55+
## Logs and Shell
4956

50-
* To monitor the logs of the container in realtime `docker logs -f mariadb`.
57+
* Shell access whilst the container is running: `docker exec -it mariadb /bin/bash`
58+
* To monitor the logs of the container in realtime: `docker logs -f mariadb`
5159

5260

5361

5462
## Versions
63+
+ **09.03.2016:** Update to mariadb 10.1. Change to use custom.cnf over my.cnf in /config. Restructured init files to change config options on startup, rather than in the dockerfile.
5564
+ **26.01.2016:** Change user of mysqld_safe script to abc, better unclean shutdown handling on restart.
5665
+ **23.12.2015:** Remove autoupdating, between some version updates the container breaks
5766
+ **12.08.2015:** Initial Release.
67+

defaults/my.cnf

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
## custom configuration file, please be aware that changing options here may break things
2+
3+
[mysqld_safe]
4+
nice = 0
5+
6+
[mysqld]
7+
max_connections = 100
8+
connect_timeout = 5
9+
wait_timeout = 600
10+
max_allowed_packet = 16M
11+
thread_cache_size = 128
12+
sort_buffer_size = 4M
13+
bulk_insert_buffer_size = 16M
14+
tmp_table_size = 32M
15+
max_heap_table_size = 32M
16+
#
17+
# * MyISAM
18+
#
19+
# This replaces the startup script and checks MyISAM tables if needed
20+
# the first time they are touched. On error, make copy and try a repair.
21+
myisam_recover_options = BACKUP
22+
key_buffer_size = 128M
23+
#open-files-limit = 2000
24+
table_open_cache = 400
25+
myisam_sort_buffer_size = 512M
26+
concurrent_insert = 2
27+
read_buffer_size = 2M
28+
read_rnd_buffer_size = 1M
29+
#
30+
# * Query Cache Configuration
31+
#
32+
# Cache only tiny result sets, so we can fit more in the query cache.
33+
query_cache_limit = 128K
34+
query_cache_size = 64M
35+
# for more write intensive setups, set to DEMAND or OFF
36+
#query_cache_type = DEMAND
37+
#
38+
# * Logging and Replication
39+
#
40+
# Both location gets rotated by the cronjob.
41+
# Be aware that this log type is a performance killer.
42+
# As of 5.1 you can enable the log at runtime!
43+
#general_log_file = /config/log/mysql/mysql.log
44+
#general_log = 1
45+
#
46+
# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
47+
#
48+
# we do want to know about network errors and such
49+
log_warnings = 2
50+
#
51+
# Enable the slow query log to see queries with especially long duration
52+
#slow_query_log[={0|1}]
53+
slow_query_log_file = /config/log/mysql/mariadb-slow.log
54+
long_query_time = 10
55+
#log_slow_rate_limit = 1000
56+
log_slow_verbosity = query_plan
57+
58+
#log-queries-not-using-indexes
59+
#log_slow_admin_statements
60+
#
61+
# The following can be used as easy to replay backup logs or for replication.
62+
# note: if you are setting up a replication slave, see README.Debian about
63+
# other settings you may need to change.
64+
#server-id = 1
65+
#report_host = master1
66+
#auto_increment_increment = 2
67+
#auto_increment_offset = 1
68+
log_bin = /config/log/mysql/mariadb-bin
69+
log_bin_index = /config/log/mysql/mariadb-bin.index
70+
# not fab for performance, but safer
71+
#sync_binlog = 1
72+
expire_logs_days = 10
73+
max_binlog_size = 100M
74+
# slaves
75+
#relay_log = /config/log/mysql/relay-bin
76+
#relay_log_index = /config/log/mysql/relay-bin.index
77+
#relay_log_info_file = /config/log/mysql/relay-bin.info
78+
#log_slave_updates
79+
#read_only
80+
#
81+
# If applications support it, this stricter sql_mode prevents some
82+
# mistakes like inserting invalid dates etc.
83+
#sql_mode = NO_ENGINE_SUBSTITUTION,TRADITIONAL
84+
#
85+
# * InnoDB
86+
#
87+
# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
88+
# Read the manual for more InnoDB related options. There are many!
89+
default_storage_engine = InnoDB
90+
# you can't just change log file size, requires special procedure
91+
#innodb_log_file_size = 50M
92+
innodb_buffer_pool_size = 256M
93+
innodb_log_buffer_size = 8M
94+
innodb_file_per_table = 1
95+
innodb_open_files = 400
96+
innodb_io_capacity = 400
97+
innodb_flush_method = O_DIRECT
98+
#
99+
# * Security Features
100+
#
101+
# Read the manual, too, if you want chroot!
102+
# chroot = /var/lib/mysql/
103+
#
104+
# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
105+
#
106+
# ssl-ca=/etc/mysql/cacert.pem
107+
# ssl-cert=/etc/mysql/server-cert.pem
108+
# ssl-key=/etc/mysql/server-key.pem
109+
110+
#
111+
# * Galera-related settings
112+
#
113+
[galera]
114+
# Mandatory settings
115+
#wsrep_on=ON
116+
#wsrep_provider=
117+
#wsrep_cluster_address=
118+
#binlog_format=row
119+
#default_storage_engine=InnoDB
120+
#innodb_autoinc_lock_mode=2
121+
#
122+
# Allow server to accept connections on all interfaces.
123+
#
124+
#bind-address=0.0.0.0
125+
#
126+
# Optional setting
127+
#wsrep_slave_threads=1
128+
#innodb_flush_log_at_trx_commit=0
129+
130+
[mysqldump]
131+
quick
132+
quote-names
133+
max_allowed_packet = 16M
134+
135+
[mysql]
136+
#no-auto-rehash # faster start of mysql but no tab completion
137+
138+
[isamchk]
139+
key_buffer_size = 16M
140+
141+
142+

init/30_config.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# make folders if required
4+
mkdir -p "$DATADIR" /var/run/mysqld /config/log/mysql
5+
6+
# configure my.cnf and mysqld_safe
7+
sed -i 's/key_buffer\b/key_buffer_size/g' /etc/mysql/my.cnf
8+
sed -ri 's/^(bind-address|skip-networking)/;\1/' /etc/mysql/my.cnf
9+
sed -i s#/var/log/mysql#/config/log/mysql#g /etc/mysql/my.cnf
10+
sed -i -e 's/\(user.*=\).*/\1 abc/g' /etc/mysql/my.cnf
11+
sed -i -e "s#\(datadir.*=\).*#\1 $DATADIR#g" /etc/mysql/my.cnf
12+
sed -i "s/user='mysql'/user='abc'/g" /usr/bin/mysqld_safe
13+
14+
# setup custom cnf file
15+
[[ ! -f /config/custom.cnf ]] && cp /defaults/my.cnf /config/custom.cnf
16+
[[ ! -L /etc/mysql/conf.d/custom.cnf && -f /etc/mysql/conf.d/custom.cnf ]] && rm /etc/mysql/conf.d/custom.cnf
17+
[[ ! -L /etc/mysql/conf.d/custom.cnf ]] && ln -s /config/custom.cnf /etc/mysql/conf.d/custom.cnf
18+
19+
# set permissions
20+
chmod -R 777 /var/run/mysqld

init/30_set_our_folders.sh

Lines changed: 0 additions & 15 deletions
This file was deleted.

init/40_set_up_dbase.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,5 @@ if [ -f "/tmp/mysql-first-time.sql" ]; then
8989
rm /tmp/mysql-first-time.sql
9090
fi
9191

92+
chown -R abc:abc /config
93+

init/50_my_cnf_set.sh

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)