From fef783248e7f4d3e3e33929a71b6a937dd20d1a8 Mon Sep 17 00:00:00 2001 From: Adnan Abdulhussein Date: Fri, 29 May 2015 14:50:46 -0700 Subject: [PATCH] Cleanup and documentation --- bitnami/mariadb/Dockerfile.pa | 8 ---- bitnami/mariadb/README.md | 75 ++++++++++++++++++++++------------- bitnami/mariadb/install.sh | 24 ----------- 3 files changed, 47 insertions(+), 60 deletions(-) delete mode 100644 bitnami/mariadb/Dockerfile.pa delete mode 100644 bitnami/mariadb/install.sh diff --git a/bitnami/mariadb/Dockerfile.pa b/bitnami/mariadb/Dockerfile.pa deleted file mode 100644 index a88cb92f7412..000000000000 --- a/bitnami/mariadb/Dockerfile.pa +++ /dev/null @@ -1,8 +0,0 @@ -FROM bitnami/pineapple - -RUN apk add --update wget && \ - wget --no-check-certificate https://downloads.bitnami.com/files/download/mariadb/bitnami-mariadb-5.5.42-0-linux-x64-installer.run -O /tmp/installer.run && \ - chmod +x /tmp/installer.run && \ - /tmp/installer.run --mode unattended --base_password bitnami --mysql_password bitnami --prefix /opt/bitnami && \ - rm -rf /tmp/* /opt/bitnami/common /opt/bitnami/mysql/data && \ - apk del wget diff --git a/bitnami/mariadb/README.md b/bitnami/mariadb/README.md index 465be4a95c72..e4df1598a29d 100644 --- a/bitnami/mariadb/README.md +++ b/bitnami/mariadb/README.md @@ -1,38 +1,41 @@ -# Bitnami MariaDB Docker Stack +# Bitnami MariaDB Docker Container + +## Introduction to Bitnami containers +Bitnami provides easy-to-use, consistently configured, and always up-to-date container images. [Click here](https://bitnami.com) for more information on our packaging approach. + +## What is MariaDB? +MariaDB is a fast, reliable, scalable, and easy to use open-source relational database system. MariaDB Server is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software. ## Usage +You can instantiate a Bitnami MariaDB container by doing: -### Running a MySQL server ``` -docker run --name mysql-server \ - -v /my-data:/data \ - -v /my-conf:/conf \ - -d bitnami/mariadb +HOST_MARIADB_CONF_DIR=`pwd`/conf +HOST_MARIADB_DATA_DIR=`pwd`/data +CONTAINER_MARIADB_SERVER_NAME=mariadb +docker run -it \ + -v $HOST_MARIADB_CONF_DIR:/conf \ + -v $HOST_MARIADB_DATA_DIR:/data \ + --name $CONTAINER_MARIADB_SERVER_NAME + bitnami/mariadb ``` -### Running the MySQL client -``` -docker run -it --link mysql-server:mysql bitnami/mariadb mysql -h mysql -P 3306 -u root -p -``` - -## Persistence - -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 and the root password will -be printed to stdout. +## Data +MariaDB data lives in $HOST_MARIADB_DATA_DIR on the host. Mapping an empty directory to `/data` inside the container will initialize the database. ## Configuration -### Pass custom arguments/flags to mysqld +### my.cnf +MariaDB configuration files live in $HOST_MARIADB_CONF_DIR on the host. You can edit the default or place your own `my.cnf` file in there. -For example, you can run the server on a different port by specifying the port option. +### Custom arguments/options +You can specify custom arguments or options to the MariaDB server command, e.g., specifying a different port: ``` -docker run --name mysql-server -d bitnami/mariadb --port=4000 +docker run ... bitnami/mariadb --port=4000 ``` - The following options cannot be overridden: + ``` --defaults-file=/opt/bitnami/mysql/my.cnf --log-error=/opt/bitnami/mysql/logs/mysqld.log @@ -46,22 +49,38 @@ The following options cannot be overridden: Anything else is fair game, you can see a full list of options here: https://dev.mysql.com/doc/refman/5.1/en/server-options.html -### my.cnf +### Environment variables -Map a volume on your host to `/config` with your custom `my.cnf` inside it, to configure MariaDB. +You can specify the `MARIADB_PASSWORD` and the `MARIADB_DATABASE` environment variables to specify a password and database to create when mounting an empty volume at `/data`. -If the volume is empty, the default configuration will be copied to your volume. +## Linking -### MySQL root password +You can start up a MariaDB client by running: -To specify a custom password, you can pass the `MYSQL_PASSWORD` environment variable when run with -an empty data volume. This will initialize the database with your chosen password. +``` +CONTAINER_MARIADB_LINK_NAME=mariadb +docker run --rm -it \ + --link $CONTAINER_MARIADB_SERVER_NAME:$CONTAINER_MARIADB_LINK_NAME bitnami/mariadb \ + mysql -h $CONTAINER_MARIADB_LINK_NAME -u root -p +``` +The client connects to the server we started in the previous command using a docker link. This exposes the `$CONTAINER_MARIADB_LINK_NAME` as the hostname for the link inside the container. We set the `-h` argument in the MariaDB client command to tell it to connect to the server running in the other container. + +Similarly, you can link the MariaDB to a container running your application, e.g., using the Bitnami node container: + +``` +CONTAINER_MARIADB_LINK_NAME=mariadb +docker run --rm -it \ + --link $CONTAINER_MARIADB_SERVER_NAME:$CONTAINER_MARIADB_LINK_NAME bitnami/node \ + npm start --production +``` +Inside your application, use the value of $CONTAINER_MARIADB_LINK_NAME when setting the MariaDB host. ## Logging The container is set up to log to stdout, which means logs can be obtained as follows: + ``` -docker logs mysql-server +docker logs mariadb ``` If you would like to log to a file instead, you can mount a volume at `/logs`. diff --git a/bitnami/mariadb/install.sh b/bitnami/mariadb/install.sh deleted file mode 100644 index 4dd08bc59096..000000000000 --- a/bitnami/mariadb/install.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash - -: ${BITNAMI_APP_DIRNAME=$BITNAMI_APP_NAME}; - -echo "===> Downloading Bitnami $BITNAMI_APP_NAME-$BITNAMI_APP_VERSION installer" -apt-get update -q && DEBIAN_FRONTEND=noninteractive apt-get install -qy wget -wget -q --no-check-certificate \ - https://downloads.bitnami.com/files/download/$BITNAMI_APP_NAME/\ -bitnami-$BITNAMI_APP_NAME-$BITNAMI_APP_VERSION-linux-x64-installer.run \ - -O /tmp/installer.run - -echo "===> Running Bitnami $BITNAMI_APP_NAME-$BITNAMI_APP_VERSION installer" -chmod +x /tmp/installer.run -/tmp/installer.run --mode unattended --prefix /opt/bitnami $@ -/opt/bitnami/$BITNAMI_APP_DIRNAME/scripts/ctl.sh stop > /dev/null - -if [ -f "/tmp/post-install.sh" ]; then - sh /tmp/post-install.sh /opt/bitnami/$BITNAMI_APP_DIRNAME -fi - -echo "===> Cleaning up" -rm -rf /tmp/* /opt/bitnami/ctlscript.sh /opt/bitnami/config -DEBIAN_FRONTEND=noninteractive apt-get --purge autoremove -qy wget -apt-get clean && rm -rf /var/lib/apt && rm -rf /var/cache/apt/archives/*