1:先下载MySQL镜像
# docker pull  mysql:5.7
 
2:运行镜像生成容器
# docker run --name mysql -p 3306:3306 -e MYSQL\_ROOT\_PASSWORD=123456  -d mysql:5.7
 
3:查看生成最新的容器
# docker ps -l
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                    NAMES
64f075017f93        mysql:5.7                  "docker-entrypoint..."   17 minutes ago      Exited (1) 16 minutes ago                                 mysql
 
4:进入容器查看是否安装成功
# docker exec -it mysql  bash
 
root@64f075017f93:/# mysql -uroot -p123456
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.22-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
 
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MySQL [(none)]>
 
5:宿主机登录测试MySQL
# mysql -uroot -p123456 -h192.168.1.20
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.22-log MySQL Community Server (GPL)
 
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MySQL [(none)]>
 
6:修改my.cnf配置文件
 
my.cnf配置文件
# cat > /etc/mysql/my.cnf <<END
[client]
port =
socket = /var/run/mysqld/mysqld.sock [mysqld]
port =
socket = /var/run/mysqld/mysqld.sock
back_log =
basedir = /usr
tmpdir = /tmp
datadir = /var/lib/mysql #-------------------gobal variables------------#
slave-parallel-type=LOGICAL_CLOCK
slave-parallel-workers=
slave_preserve_commit_order= on
gtid_mode = ON
relay_log_info_repository = TABLE
master_info_repository = TABLE
relay_log_recovery = on
enforce_gtid_consistency = ON
binlog_checksum = NONE
log_slave_updates = ON
log-bin = /var/lib/mysql/mysql-bin
max_connect_errors =
max_connections =
wait_timeout =
interactive_timeout =
net_read_timeout =
net_write_timeout =
table_open_cache =
table_definition_cache =
thread_cache_size =
open_files_limit =
character-set-server = utf8
collation-server = utf8_bin
skip_external_locking
performance_schema =
user = mysql
myisam_recover_options = DEFAULT
skip-name-resolve
local_infile =
lower_case_table_names = #--------------------innoDB------------#
innodb_buffer_pool_size = 2000M
innodb_data_file_path = ibdata1:200M:autoextend
innodb_flush_log_at_trx_commit =
innodb_io_capacity =
innodb_lock_wait_timeout =
innodb_log_buffer_size = 8M
innodb_log_file_size = 200M
innodb_log_files_in_group =
innodb_max_dirty_pages_pct =
innodb_read_io_threads =
innodb_write_io_threads =
innodb_support_xa =
innodb_thread_concurrency =
innodb_file_per_table
innodb_rollback_on_timeout #------------session variables-------#
join_buffer_size = 8M
key_buffer_size = 256M
bulk_insert_buffer_size = 8M
max_heap_table_size = 96M
tmp_table_size = 96M
read_buffer_size = 8M
sort_buffer_size = 2M
max_allowed_packet = 64M
read_rnd_buffer_size = 32M #------------MySQL Log----------------#
log-bin = my3306-bin
binlog_format = row
sync_binlog =
expire_logs_days =
max_binlog_cache_size = 128M
max_binlog_size = 500M
binlog_cache_size = 64k
slow_query_log
log-slow-admin-statements
log_warnings =
long_query_time = 0.25 #---------------replicate--------------#
relay-log-index = relay3306.index
relay-log = relay3306
server-id =
init_slave = 'set sql_mode=STRICT_ALL_TABLES'
log-slave-updates
[myisamchk]
key_buffer = 512M
sort_buffer_size = 512M
read_buffer = 8M
write_buffer = 8M
[mysql]
prompt=MySQL [\\d]>
default-character-set=utf8
[mysqlhotcopy]
interactive-timeout
[mysqld_safe]
open-files-limit =
log-error = /var/lib/mysql/mysqld_error.log
END
 
7:生成新的镜像
# docker commit 64f075017f93  mysql:5.7.22
 
8:查看镜像
# docker images
REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
mysql                        5.7.22              1bc73a7082d4        20 minutes ago      372MB
mysql                        5.7                     66bc0f66b7af        2 weeks ago         372MB
 
9:测试新的镜像是否生效
# docker run --name mysql_test  -p 3306:3306 -e MYSQL\_ROOT\_PASSWORD=123456  -d mysql:5.7.22
# docker exec -it mysql_test  bash   
查看/etc/mysql/my.cnf配置文件
 
宿主机登陆测试MySQL数据库
# mysql -uroot -p123456 -h192.168.1.20
 
 
 
 

docker重新打包MySQL5.7镜像的更多相关文章

  1. 通过docker把本地AspNetCore WebAPI镜像打包到阿里云镜像仓库并在centos部署

    在centos上安装docker # step 1: 安装必要的一些系统工具 sudo yum install -y yum-utils device-mapper-persistent-data l ...

  2. Docker中运行MySQL5.7并挂载宿主机目录到镜像

    原文:Docker中运行MySQL5.7并挂载宿主机目录到镜像 1.1 拉取mysql镜像 docker pull mysql:5.7 1.2 创建用于挂载的目录 mkdir -p /data/mys ...

  3. docker:(1)docker基本命令使用及发布镜像

    docker镜像可以完全看作一台全新的电脑使用,无论什么镜像都是对某一东西进行了配置,然后打包后可以快速移植到需要的地方直接使用 省去复杂的配置工作 比如java web项目部署,如果是新部署,需要装 ...

  4. Docker + webpack 打包前端项目

    码云代码地址: https://gitee.com/caonimashi/docker_deployment_front_end    构建基础镜像: 1.下载一个 Apline Linux 操作系统 ...

  5. Docker实践之02-使用镜像及定制

    目录 一.获取镜像 二.使用镜像启动容器实例 三.列出镜像 四.删除本地镜像 五.定制镜像 通过commit命令定制镜像 通过Dockerfile定制镜像 docker build的工作原理 dock ...

  6. CentOS7 Docker私有仓库搭建及删除镜像 【转】

    文章来源:centos7 Docker私有仓库搭建及删除镜像 如果不想用私有镜像库,你可以用docker的库 https://hub.docker.com 环境准备 环境:两个装有Docker 17. ...

  7. 手把手使用Docker搭建SpringBoot微服务镜像

    一.环境准备 1.安装好Docker环境的Linux机器(安装教程) 2.准备好SpringBoot项目打包好的可运行jar包 二.编写Dockerfile 1.首先将SpringBoot打包好的ja ...

  8. Docker详细介绍安装与镜像制作和拉取

    一.Docker是什么? 产生背景: 开发和运维之间因为环境不同和导致的矛盾(不同的操作系统.软件环境.应用配置等)DevOps 代码.系统.环境.配置等封装成镜像Image--->运维: 集群 ...

  9. centos7 Docker私有仓库搭建及删除镜像

    如果不想用私有镜像库,你可以用docker的库 https://hub.docker.com 环境准备 环境:两个装有Docker 17.09.0-ce 的centos7虚拟机 虚拟机一:192.16 ...

随机推荐

  1. Linux下磁盘分区、挂载、卸载操作记录

    Linux下磁盘分区.挂载.卸载操作记录. 操作环境:CentOS release 6.5 (Final) Last :: from 118.230.194.76 [root@CentOS ~]# [ ...

  2. 双摆模拟 python(转)

    双摆 是 混沌理论 中的一个常见示例,这里通过 python 的作图工具包Matplotlib 来模拟双摆的运动过程: 注意:在 vs2017 中可以正确运行程序,在 cmd 环境下有时报错 &quo ...

  3. 236 Lowest Common Ancestor of a Binary Tree 二叉树的最近公共祖先

    给定一棵二叉树, 找到该树中两个指定节点的最近公共祖先. 详见:https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tre ...

  4. Spring Boot (31) 数据验证

    曾经参数的验证是这样的: public String test(User user){ if(user == null){ throw new NullPointerException("u ...

  5. Laravel5.1学习笔记23 Eloquent 序列化

    Eloquent: Serialization Introduction Basic Usage Hiding Attributes From JSON Appending Values To JSO ...

  6. Windows下压缩成tar.gz格式

    tar.gz 是linux和unix下面比较常用的格式,几个命令就可以把文件压缩打包成tar.gz格式,然而这种格式在windows并不多见,WinRAR.WinZip等主流压缩工具可以释放解开,却不 ...

  7. java内存组成

     java内存组成介绍:堆(Heap)和非堆(Non-heap)内存 按照官方的说法:“Java 虚拟机具有一个堆,堆是运行时数据区域,所有类实例和数组的内存均从此处分配.堆是在 Java 虚拟机启动 ...

  8. RabbitMQ系列(五)--高级特性

    在上一篇文章讲解MQ消息可靠性投递和幂等性中有提到confirm机制的重要性,现在更相信的说明一下 一.Confirm机制 Confirm就是消息确认,当Producer发送消息,如果Broker收到 ...

  9. CodeFrist基础_迁移更新数据

    一丶自动迁移 第一次启用迁移:NeGet-->Enable-Migrations public DemoDbContext() : base("name=ConncodeFirst&q ...

  10. c++通过CMake实现debug开关

    刚学cmake,很多东西还不是很懂,不过今天刚刚实现了通过CMake控制debug的开关,兴奋之余记录一下. 背景介绍: 最近参与到了一个大的C++项目,很多代码已经非常成熟,我来添加一些辅助功能,但 ...