This package contains mysql-server on ubuntu:14.04

【How to build】
cd /home/ops/work/demo/docker/aws/mysql
touch Dockerfile
docker build -t aws_mysql_image:v1.0 .

【Test】
docker run -id -p 8888:3306 --name aws_mysql_container aws_mysql_image:v1.0 /bin/bash
docker exec -it aws_mysql_container /bin/bash
service mysql start
mysql -h localhost -uroot -padminadmin

【Dockerfile】
FROM ubuntu:14.04
MAINTAINER jbding <157517301@qq.com>
RUN apt-get update
RUN apt-get install -y mysql-server

RUN /etc/init.d/mysql start \
&& mysql -uroot -e "grant all privileges on *.* to 'root'@'%' identified by 'root';" \
&& mysql -uroot -e "grant all privileges on *.* to 'root'@'localhost' identified by 'root';"

RUN sed -Ei 's/^(bind-address|log)/#&/' /etc/mysql/my.cnf \
&& echo 'skip-host-cache\nskip-name-resolve' | awk '{ print } $1 == "[mysqld]" && c == 0 { c = 1; system("cat") }' /etc/mysql/my.cnf > /tmp/my.cnf \
&& mv /tmp/my.cnf /etc/mysql/my.cnf

EXPOSE 3306
CMD ["/usr/bin/mysqld_safe"]

posted @ 2017-12-05 13:52  BigBra  阅读(247)  评论(0编辑  收藏  举报