各位大佬 我用dockerfile安装了mysql容器怎么挂载数据文件目录

2025-02-25 12:47:26
推荐回答(1个)
回答1:

1. 首先创建一个目录并在目录下创建一个Dockerfile,文件内容如下

[plain] view plain copy print?
FROM centos:centos6
MAINTAINER Fanbin Kong "kongxx@hotmail.com"

RUN yum install -y mysql-server mysql

RUN /etc/init.d/mysqld start &&\
mysql -e "grant all privileges on *.* to 'root'@'%' identified by 'letmein';"&&\
mysql -e "grant all privileges on *.* to 'root'@'localhost' identified by 'letmein';"&&\
mysql -u root -pletmein -e "show databases;"

EXPOSE 3306

CMD ["/usr/bin/mysqld_safe"]