标签:cat lda 搭建 分享 create existing rip etc clean
整理了一下文档 今天来构建mariadb
主机还是 centos 172.16.0.200 构建第二个images
mkdir ./mysql-dockerfile 下面有三个文件
Dockerfile #构建mariadb-images
mysqld_charset.cnf #mariadb #配置文件 就设置了编码格式
script #目录内,存放三个文件
script #目录下三个文件
好了 我们一个一个来看一下
Dockerfile
FROM docker.io/centos
MAINTAINER Mrchen <237356573@qq.com>
#add system-path
ENV DATA_DIR /var/lib/mysql
# Install Mariadb
RUN yum install -y mariadb mariadb-server && yum clean all
#add mysql.conf
ADD mysqld_charset.cnf /etc/my.cnf.d/
COPY script /script
RUN chmod +x /script/start
mysqld_charset.cnf #设置mysql 编码配置
[mysqld]
character_set_server=utf8
character_set_filesystem=utf8
collation-server=utf8_general_ci
init-connect=‘SET NAMES utf8‘
init_connect=‘SET collation_connection = utf8_general_ci‘
/script/start
if [[ -e /script/mark ]]; then
# config mariadb
/script/run_maria
rm /script/mark
else
# Cleanup previous mariadb sockets
if [[ -e ${DATA_DIR}/mysql.sock ]]; then
rm -f ${DATA_DIR}/mysql.sock
fi
fi
exec /usr/bin/mysqld_safe
run_maria 初始mariadb user password 。。。。
#!/bin/bash DB_USER=${DB_USER:-admin} DB_PASS=${DB_PASS:-admin} MARIADB_NEW=true # # MariaDB setup # run_maria() { # First install mariadb if [[ ! -d ${DATA_DIR}/mysql ]]; then echo "===> MariaDB not install..." echo "===> Initializing maria database... " mysql_install_db --user=mysql --ldata=${DATA_DIR} echo "===> System databases initialized..." # Start mariadb /usr/bin/mysqld_safe --user mysql > /dev/null 2>&1 & echo "===> Waiting for MariaDB to start..." STA=1 while [[ STA -ne 0 ]]; do printf "." sleep 5 mysql -uroot -e "status" > /dev/null 2>&1 STA=$? done echo "===> Start OK..." # 1. Create a localhost-only admin account mysql -u root -e "CREATE USER ‘$DB_USER‘@‘%‘ IDENTIFIED BY ‘$DB_PASS‘" mysql -u root -e "CREATE USER ‘$DB_USER‘@‘localhost‘ IDENTIFIED BY ‘$DB_PASS‘" mysql -u root -e "CREATE USER ‘$DB_USER‘@‘127.0.0.1‘ IDENTIFIED BY ‘$DB_PASS‘" mysql -u root -e "GRANT ALL PRIVILEGES ON *.* TO ‘$DB_USER‘@‘%‘ WITH GRANT OPTION" echo "===> Create localhost completed..." # shutdown mariadb to wait for supervisor mysqladmin -u root shutdown else if [[ -e ${DATA_DIR}/mysql.sock ]]; then rm -f ${DATA_DIR}/mysql.sock fi MARIADB_NEW=false echo "===> Using an existing volume of MariaDB" fi } run_maria
好了现在开始build images
查看一下 本地基础镜像:
docker images
docker build -t python-mysql:mariadb-v1 .
查看build 完成后images
docker images
启动容器 :
docker run --name python-sql -d -p 3306:3306 python-mysql:mariadb-v1
navicat_Mysql 连接测试
别忘了:setenforce 0
Docker 一步一步 搭建开源 CMDB平台 第二步: DockerFile 构建mariadb
标签:cat lda 搭建 分享 create existing rip etc clean
原文地址:http://www.cnblogs.com/python-diy/p/7684455.html