Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mariadb dockerfile can do directory mapping.

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

[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

Total dosage 16

-rw-r--r-- 1 root root 287 June 10 14:43 Dockerfile

-rw-r--r-- 1 root root 6 June 6 10:26 MariaDB.repo

-rw-r--r-- 1 root root 316 June 10 16:02 run.sh

-rw-r--r-- 1 root root 109 June 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 name mariadb5 mytest/mariadb10.3 3306-v / data/dockertest/mysql:/var/lib/mysql-- name mariadb5 mytest/mariadb10.3

Mysql-h227.0.0.1-uroot-P3306-p123456

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report