Public Repository

Last pushed: a year ago
Short Description
Interactive container + MySQL daemon running.
Full Description

[starting up a container]

docker run --net=host --name=debian-mysql -it ivanlmj/debian-8-mysql-5.7.12

  • --net=host : container network exposed to host machine
  • -it : interactive container (MySQL daemon will be started and a BASH will be spawned - see Dockerfile bellow

[connecting to MySQL - inside and outside the container]

mysql -h 127.0.0.1 -u root -pdrootmysql

[Dockerfile]

FROM debian:jessie

MAINTAINER Ivan Leon (ivanlmj@gmail.com) - @ivanleoncz

configuring MySQL 5.7.12 Official Repo for Debian Jessie

RUN echo "deb http://repo.mysql.com/apt//debian/ jessie mysql-apt-config" >> /etc/apt/sources.list \
&& echo "deb http://repo.mysql.com/apt//debian/ jessie mysql-5.7" >> /etc/apt/sources.list \
&& echo "deb http://repo.mysql.com/apt//debian/ jessie connector-python-2.0 connector-python-2.1 router-2.0 mysql-utilities-1.5 mysql-tools" >> /etc/apt/sources.list \

ensuring that MySQL will not ask for password setup, assuming no password setup for 'root' user

&& export DEBIAN_FRONTEND=noninteractive \

installing MySQL Server

&& apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8C718D3B5072E1F5 && apt-get update && apt-get -y install mysql-server=5.7.12-1debian8 libmysqlclient20 \

cleaning APT cache

&& apt-get clean && rm -rf /var/lib/apt/lists/* \

inserting important parameters for UTF-8 compatibility

&& echo -e "\ncharacter-set-server=utf8 \
\ncollation-server=utf8_general_ci \
\nskip-character-set-client-handshake" >> /etc/mysql/my.cnf \

starting MySQL daemon for the next steps

&& service mysql start \

creating root user with access to MySQL via 127.0.0.1 (making MySQL visible to the host machine)

&& mysql -e "CREATE USER root@127.0.0.1 IDENTIFIED BY 'drootmysql';" \

granting privileges on all dbases

&& mysql -e "GRANT ALL PRIVILEGES ON . TO 'root'@'127.0.0.1';" \

dropping root user which uses localhost name for connecting to MySQL

&& mysql -e "DROP USER 'root'@'localhost';" \

flushing cached memory

&& mysql -h 127.0.0.1 -u root -pdrootmysql -e "FLUSH PRIVILEGES;"

passing commands as parameters for default Docker ENTRYPOINT (/bin/sh -c): starting MySQL daemon + spawning BASH for container interaction

CMD service mysql start && /bin/bash

Docker Pull Command
Owner
ivanlmj

Comments (0)