[root@mytest mariadb10.3]# cat Dockerfile
FROM centos
MAINTAINER xingzhenxiang 20190610
ADD MariaDB.repo /etc/yum.repos.d/MariaDB.repo
RUN yum install -y MariaDB-server
ENV PASSWD 123456
RUN yum clean all
RUN chmod 777 -R /var/lib/mysql
ADD run.sh /
RUN chmod 755 /run.sh
# Expose ports.
VOLUME /var/lib/mysql
EXPOSE 3306
CMD ["/run.sh"]
[root@mytest mariadb10.3]# cat run.sh
#!/bin/bash
cp /usr/share/mysql/mysql.server /etc/init.d/mysql.server
mysql_install_db --user=mysql
#sleep 20
/etc/init.d/mysql.server start
sleep 20
mysql -uroot -e "update mysql.user set host='%',password=password($PASSWD) where host='::1'; flush privileges;"
sleep 20
tail -f /var/lib/mysql/`hostname`.err
[root@mytest mariadb10.3]# ll
总用量 16
-rw-r--r-- 1 root root 287 6月 10 14:43 Dockerfile
-rw-r--r-- 1 root root 173 6月 6 10:26 MariaDB.repo
-rw-r--r-- 1 root root 316 6月 10 16:02 run.sh
-rw-r--r-- 1 root root 109 6月 6 12:28 run.sh.bak
[root@mytest mariadb10.3]# cat MariaDB.repo
[mariadb]
name = MariaDB
baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/
gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1
[root@mytest mariadb10.3]#
docker build -t mytest/mariadb10.3 .
docker run -d -p 3306:3306 -v /data/dockertest/mysql:/var/lib/mysql --name mariadb5 mytest/mariadb10.3
mysql -h227.0.0.1 -uroot -P3306 -p123456
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。