龙空技术网

构建基于mysql5.7的docker容器

Dobbyisfree 114

前言:

现在姐妹们对“localesubuntu”大体比较关注,咱们都想要了解一些“localesubuntu”的相关知识。那么小编也在网摘上汇集了一些有关“localesubuntu””的相关文章,希望兄弟们能喜欢,各位老铁们快快来了解一下吧!

创建目录

cd ~mkdir mysql57

国内镜像文件buster.sources.list

deb  buster main non-free contribdeb  buster-updates main non-free contribdeb  buster-backports main non-free contribdeb  buster/updates main non-free contribdeb-src  buster main non-free contribdeb-src  buster-updates main non-free contribdeb-src  buster-backports main non-free contribdeb-src  buster/updates main non-free contrib
mysql配置文件my.cnf
[client]port		= 3306socket		= /var/run/mysqld/mysqld.sockdefault-character-set = utf8[mysqld_safe]pid-file	= /var/run/mysqld/mysqld.pidsocket		= /var/run/mysqld/mysqld.socknice		= 0[mysql]no-auto-rehashdefault-character-set = utf8[mysqld]user		= mysqlpid-file	= /var/run/mysqld/mysqld.pidsocket		= /var/run/mysqld/mysqld.sockport		= 3306basedir		= /usrdatadir		= /var/lib/mysqltmpdir		= /tmplc-messages-dir	= /usr/share/mysqlexplicit_defaults_for_timestampinit_connect = 'SET collation_connection = utf8_unicode_ci'init_connect = 'SET NAMES utf8'character-set-server = utf8collation-server = utf8_unicode_ci#skip-character-set-client-handshake# Instead of skip-networking the default is now to listen only on# localhost which is more compatible and is not less secure.#bind-address	= 127.0.0.1#log-error	= /var/log/mysql/error.log# Recommended in standard MySQL setupsql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# * IMPORTANT: Additional settings that can override those from this file!#   The files must end with '.cnf', otherwise they'll be ignored.#!includedir /etc/mysql/conf.d/# 自定义扩展mysql的配置可以写在这里,优先级最高!includedir /etc/mysql/mysql-my.conf.d/
Dockerfile
FROM mysql:5.7.33# 维护者信息MAINTAINER kennylee <kennylee26@gmail.com>RUN mv /etc/apt/sources.list /etc/apt/sources.list.bakCOPY buster.sources.list /etc/apt/sources.list# 特别注意这句话,可能会有报错信息,如果报错 打开注释并将467B942D3A79BD29替换为错误信息中提示的key值# RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29RUN apt-get update && \    apt-get install -y curl git unzip vim wget && \    apt-get install -y locales kde-l10n-zhcn && \     apt-get clean && \    rm -rf /var/lib/apt/lists/*RUN sed -i 's/# zh_CN.UTF-8 UTF-8/zh_CN.UTF-8 UTF-8/g' /etc/locale.genRUN locale && locale-gen "zh_CN.UTF-8"       # Set environment variables.ENV LANG=zh_CN.UTF-8 \    LANGUAGE=zh_CN:zh:en_US:en \    LC_ALL=zh_CN.UTF-8 \    TZ=Asia/Shanghai \    DEBIAN_FRONTEND="noninteractive" \    TERM=xterm \	MYSQL_ROOT_PASSWORD=rootRUN ln -fs /usr/share/zoneinfo/$TZ /etc/localtime && \            echo $TZ > /etc/timezone && \                    dpkg-reconfigure --frontend noninteractive tzdata && \            dpkg-reconfigure --frontend noninteractive localesCOPY my.cnf /etc/mysql/my.cnfRUN mkdir -p /etc/mysql/mysql-my.conf.d/EXPOSE  3306CMD ["mysqld"]
构建命令
docker build -t kennylee/mysql ./
启动
docker container run -d --rm -p 33006:3306 -it kennylee/mysql
查看启动日志
docker psdocker logs 9a70ae62167f

标签: #localesubuntu