Setting up a MySQL Docker Container

Post on 13-Jan-2017

283 views 5 download

transcript

Setting Up a MySQLDocker Container

Víctor S. RecioCEO NerCore Inc,@vsreciovrecio@nercore.com

Lead● Docker Santo Domingo● Linux Dominicana● Golang Dominicana● OpenSaturday

Who am I?

Demos

Docker-> $ A Quick Introduction to Docker-> $ Docker Toolbox

MySQL-> $ World’s Most Popular Open Source Database-> $ Industry Leaders Rely on MySQL-> $ MySQL Enterprise Edition-> $ MySQL Community Server

Setting a MySQL Container-> $ Environment Variables-> $ Starting a MySQL instance-> $ Data Container

Agenda

A Quick Introduction to Docker

Docker

Docker

Docker Toolbox

MySQLWorld’s Most Popular Open Source Database

● Over 25 million estimated installations● Over 10M of pulls in hub.docker.com 5M more than PostgreSQL● Used by 8 of top 10 web sites in the world● Embedded by 8 of the top 10 ISVs● #1 database in the Cloud● Integrated w/Hadoop in 80% of Big Data platforms

Industry Leaders Rely on MySQL

MySQL

MySQL Enterprise Edition

MySQL

MySQL Enterprise Edition includes the most comprehensive set of advanced features, management tools and technical support to achieve the highest levels of MySQL scalability, security, reliability, and uptime.

● MySQL Database

● MySQL Enterprise Backup

● MySQL Enterprise High Availability

● MySQL Enterprise Scalability

● MySQL Enterprise Authentication

● MySQL Enterprise Encryption

● MySQL Enterprise Firewall

● MySQL Enterprise Audit

● MySQL Enterprise Monitor

● Enterprise Manager for MySQL

● MySQL Query Analyzer

● 225+ MySQL Advisors

● 600+ Monitored Variables

● 60+ Performance Graphs

● MySQL Workbench

● Oracle Premier Support

MySQL Community Server

MySQL

● MySQL Community Server (GPL)● MySQL Cluster (GPL)● MySQL Fabric (GPL)● MySQL Router (GPL)● MySQL Utilities (GPL)● MySQL Workbench (GPL)● MySQL Connectors

MySQL Community Edition is a freely downloadable version of the world's most popular open source database that is supported by an active community of open source developers and enthusiasts.

Setting a MySQL ContainerWhen 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.

MYSQL_ROOT_PASSWORDMYSQL_RANDOM_ROOT_PASSWORDMYSQL_DATABASEMYSQL_USERMYSQL_PASSWORDMYSQL_ALLOW_EMPTY_PASSWORDMYSQL_HOSTMYSQL_TCP_PORT

FROM oraclelinux:latestENV PACKAGE_URL https://repo.mysql.com/yum/mysql-5.7-community/docker/x86_64/mysql-community-server-minimal-5.7.11-1.el7.x86_64.rpm

# Install serverRUN rpmkeys --import http://repo.mysql.com/RPM-GPG-KEY-mysql \ && yum install -y $PACKAGE_URL \ && yum install -y libpwquality \ && rm -rf /var/cache/yum/*RUN mkdir /docker-entrypoint-initdb.d

VOLUME /var/lib/mysql

COPY docker-entrypoint.sh /entrypoint.shENTRYPOINT ["/entrypoint.sh"]

EXPOSE 3306CMD ["mysqld"]

Starting a MySQL instanceDockerfile

docker \

run \

--detach \

--env MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD} \

--env MYSQL_USER=${MYSQL_USER} \

--env MYSQL_PASSWORD=${MYSQL_PASSWORD} \

--env MYSQL_DATABASE=${MYSQL_DATABASE} \

--name ${MYSQL_CONTAINER_NAME} \

--publish 3306:3306 \

mysql:5.7;

Starting a MySQL instanceDocker run

Data ContainerA common practice is to create a data container -- container whose sole purpose is to share data between other container. The main benefit of this approach is tha it provides a handy namespaces for volumenes that can be easily loaded using --volumes-from command.

$ docker run --name dbdata mysql echo “Data-only container for MySQL”

$ docker run -d --volumenes-from dbdata --name db1 mysql

Demos

Thanks!Víctor S. RecioCEO NerCore Inc,@vsreciolinkedin.com/in/vsreciovrecio@nercore.com

CEO NerCore Inc,