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 -u root -pdrootmysql


FROM debian:jessie

MAINTAINER Ivan Leon ( - @ivanleoncz

configuring MySQL 5.7.12 Official Repo for Debian Jessie

RUN echo "deb jessie mysql-apt-config" >> /etc/apt/sources.list \
&& echo "deb jessie mysql-5.7" >> /etc/apt/sources.list \
&& echo "deb 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 --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 (making MySQL visible to the host machine)

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

granting privileges on all dbases

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

dropping root user which uses localhost name for connecting to MySQL

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

flushing cached memory

&& mysql -h -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

Comments (0)