Add log file support to mariadb

This commit is contained in:
Adnan Abdulhussein
2015-05-20 20:07:10 -07:00
parent 787b52b67b
commit d5f2a83d46
3 changed files with 10 additions and 3 deletions
+3 -1
View File
@@ -8,16 +8,18 @@ RUN apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get install -qy wget
/opt/bitnami/mysql/scripts/ctl.sh stop mysql > /dev/null && \
echo "bin/mysql -S /opt/bitnami/mysql/tmp/mysql.sock -u root -p\$2 -e \"GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '\$2' WITH GRANT OPTION;\"" >> /opt/bitnami/mysql/scripts/myscript.sh && \
rm -rf /tmp/* /opt/bitnami/mysql/data /opt/bitnami/ctlscript.sh && \
mkdir /opt/bitnami/mysql/logs && ln -s /dev/stdout /opt/bitnami/mysql/logs/mysqld.log && \
mkdir /opt/bitnami/mysql/conf.defaults && \
mv /opt/bitnami/mysql/my.cnf /opt/bitnami/mysql/conf.defaults/ && \
ln -s /opt/bitnami/mysql/conf/my.cnf /opt/bitnami/mysql/my.cnf && \
ln -s /opt/bitnami/mysql/conf /conf && \
ln -s /opt/bitnami/mysql/data /data && \
ln -s /opt/bitnami/mysql/logs /logs && \
DEBIAN_FRONTEND=noninteractive apt-get --purge autoremove -qy wget && apt-get clean && rm -rf /var/lib/apt && rm -rf /var/cache/apt/archives/*
ENV PATH /opt/bitnami/mysql/bin:$PATH
EXPOSE 3306
VOLUME ["/data", "/conf"]
VOLUME ["/data", "/conf", "/logs"]
COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
+4 -1
View File
@@ -21,7 +21,8 @@ docker run --link mysql-server:mysql bitnami/mariadb \
Map a volume on your host to `/data` to persist your database when the container is removed.
If the volume is empty, the database will be initialized in your volume.
If the volume is empty, the database will be initialized in your volume and the root password will
be printed to stdout.
## Configuration
@@ -50,3 +51,5 @@ The container is set up to log to stdout, which means logs can be obtained as fo
```
docker logs mysql-server
```
If you would like to log to a file instead, you can mount a volume at `/logs`.
+3 -1
View File
@@ -8,7 +8,7 @@ fi
if [ "$1" = 'mysqld.bin' ]; then
set -- "$@" --defaults-file=/opt/bitnami/mysql/my.cnf --basedir=/opt/bitnami/mysql --datadir=/opt/bitnami/mysql/data --plugin-dir=/opt/bitnami/mysql/lib/plugin --user=mysql --socket=/opt/bitnami/mysql/tmp/mysql.sock$EXTRA_OPTIONS
set -- "$@" --defaults-file=/opt/bitnami/mysql/my.cnf --log-error=/opt/bitnami/mysql/logs/mysqld.log --basedir=/opt/bitnami/mysql --datadir=/opt/bitnami/mysql/data --plugin-dir=/opt/bitnami/mysql/lib/plugin --user=mysql --socket=/opt/bitnami/mysql/tmp/mysql.sock$EXTRA_OPTIONS
if [ ! "$(ls -A /conf)" ]; then
echo "Copying default configuration to /conf/my.cnf..."
@@ -34,6 +34,8 @@ if [ "$1" = 'mysqld.bin' ]; then
su mysql -c "sh /opt/bitnami/mysql/scripts/myscript.sh /opt/bitnami/mysql $MYSQL_PASSWORD"
/opt/bitnami/mysql/scripts/ctl.sh stop mysql > /dev/null
fi
chown mysql:mysql -R /opt/bitnami/mysql/logs
fi
exec "$@"