• 编写Dockerfile生成项目导入定制化的数据表数据的mysql镜像


    初始化数据库的sql文件

    # cat lagou.sql

    SET NAMES utf8;
    DROP DATABASE IF EXISTS lagou;
    create database lagou CHARSET=utf8 COLLATE=utf8_general_ci;
    use lagou;
    DROP TABLE IF EXISTS `tbuser`;
    CREATE TABLE `tbuser` 
    ( `userid` int(11) NOT NULL AUTO_INCREMENT,
    `username` varchar(20) COLLATE utf8_general_ci DEFAULT NULL, 
    `password` varchar(20) COLLATE utf8_general_ci DEFAULT NULL, 
    `userroles` varchar(2) COLLATE utf8_general_ci DEFAULT NULL,
    `nickname` varchar(50) COLLATE utf8_general_ci DEFAULT NULL,
    PRIMARY KEY (`userid`) ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;
    INSERT INTO tbuser (username,PASSWORD,userroles,nickname) VALUES ('admin','1234','04','管理员'),('lagou','1234','03','拉勾教育');

    编写Dockerfile

    # cat Dockerfile

    FROM mysql:5.7.31
    MAINTAINER mysql from date UTC by Asia/Shanghai "jack@163.com"
    ENV TZ Asia/Shanghai
    
    COPY lagou.sql /docker-entrypoint-initdb.d

    编译并推送镜像到仓库

    docker build -t 10.9.3.231:5000/lagouedu/mysql:5.7.1 .
    docker push 10.9.3.231:5000/lagouedu/mysql:5.7.1

    运行容器

    # docker run -it -d --name mysql01 --restart always -p 3306:3306 --privileged=true -e MYSQL_ROOT_PASSWORD=root -v /data/mysql_data:/var/lib/mysql 10.9.3.231:5000/lagouedu/mysql:5.7.1 --character-set-server=utf8 --collation-server=utf8_general_ci

     

     

  • 相关阅读:
    Find the capitals
    Area of a Circle
    SequenceSum
    使用Eclipse设定Android开发环境
    hdu 1290 竭诚为杭州电礼物50周年
    oracle connect by 说明
    CSS截取字符串,额外的文本显示以省略号
    动态规划——背包问题
    【MySQL笔记】mysql来源安装/配置步骤和支持中国gbk/gb2312编码配置
    博客搬到了http://xianglong.me
  • 原文地址:https://www.cnblogs.com/reblue520/p/15433123.html
Copyright © 2020-2023  润新知