Dockerfile:mysql镜像编写

mysql镜像在centos6.7上的Dockerfile实现如下:

FROM centos:6.7
MAINTAINER chenyufeng "[email protected]"  

# 使用yum的方式安装mysql;
RUN yum install -y mysql-server mysql  

# 安装完成以后,执行以下命令。配置用户名密码相关信息;
RUN /etc/init.d/mysqld start &&\  
    mysql -e "grant all privileges on *.* to 'root'@'%' identified by '123456' WITH GRANT OPTION ;"&&\  
    mysql -e "grant all privileges on *.* to 'root'@'localhost' identified by '123456' WITH GRANT OPTION ;"&&\ 
    mysql -u root -p123456 -e "show databases;"  

# 镜像暴露3306端口;
EXPOSE 3306

# 容器启动后执行以下命令,启动mysql;
CMD ["/usr/bin/mysqld_safe"]


目前该镜像已经上传至Docker hub,可以直接使用以下命令拉取到本地使用:

docker pull chenyufeng/mysql-centos


你可能感兴趣的:(Dockerfile:mysql镜像编写)