1: Download MySQL image # Docker pull mysql:5.7 2: Run Image Build container # docker run--name mysql-p 3306:3306-e mysql\_ root\_password=123456 -d mysql:5.7 3: View generate latest Container # Docker Ps-lcontainer id IMAGE COMMAND created status PORTS names64f075017f93 mysql:5.7 "Docker-entrypoint ..." 17 minutes AGO&Nbsp; exited (1) Minutes ago mysql 4: Enter the container to see if the installation succeeded # Docker exec-it Mysql bash [email protected]:/# mysql-uroot-p123456welcome to the MySQL monitor. commands end with; or \g.your MySQL connection ID is 3Server 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 itsaffiliates. Other names is trademarks of their respectiveowners. type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement. mysql [(None)]> 5: Host login test mysql# mysql-uroot-p123456-h192.1 68.1.20Welcome to the MariaDB monitor. commands end with; or \g.your MySQL conNection ID is 4Server version:5.7.22-log MySQL Community Server (GPL) copyright (c), Oracle, MariaDB Corp Oration Ab and Others. type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement. mysql [(none)]> 6: Modify MY.CNF configuration file my.cnf profile
#Cat>/etc/mysql/my.cnf <<End[client]port=3306Socket=/var/run/mysqld/Mysqld.sock [Mysqld]port=3306Socket=/var/run/mysqld/Mysqld.sockback_log= theBasedir= /Usrtmpdir= /Tmpdatadir=/var/lib/MySQL #-------------------Gobal Variables------------#slave-parallel-type=Logical_clockslave-parallel-workers= -Slave_preserve_commit_order=Ongtid_mode=onrelay_log_info_repository=TABLE master_info_repository=TABLE relay_log_recovery=onenforce_gtid_consistency=Onbinlog_checksum=nonelog_slave_updates=ONlog-bin =/var/lib/mysql/mysql-binmax_connect_errors=20000max_connections= -Wait_timeout=3600Interactive_timeout=3600Net_read_timeout=3600Net_write_timeout=3600Table_open_cache=1024x768Table_definition_cache=1024x768thread_cache_size= +Open_files_limit=10000character-set-server =utf8collation-server =Utf8_binskip_external_lockingperformance_schema=1User=mysqlmyisam_recover_options=Defaultskip-name-Resolvelocal_infile=0Lower_case_table_names=0 #--------------------InnoDB------------#innodb_buffer_pool_size=2000minnodb_data_file_path=Ibdata1:200m:autoextendinnodb_flush_log_at_trx_commit=1innodb_io_capacity= -Innodb_lock_wait_timeout= -innodb_log_buffer_size=8minnodb_log_file_size=200minnodb_log_files_in_group=3innodb_max_dirty_pages_pct= -innodb_read_io_threads=8innodb_write_io_threads=8Innodb_support_xa=1innodb_thread_concurrency= +Innodb_file_per_tableinnodb_rollback_on_timeout #------------Session Variables-------#join_buffer_size=8mkey_buffer_size=256mbulk_insert_buffer_size=8mmax_heap_table_size=96mtmp_table_size=96mread_buffer_size=8msort_buffer_size=2mmax_allowed_packet=64mread_rnd_buffer_size=32M #------------MySQL Log----------------#log-bin = my3306-Binbinlog_format=Rowsync_binlog=1expire_logs_days= themax_binlog_cache_size=128mmax_binlog_size=500mbinlog_cache_size=64kslow_query_loglog-slow-admin-statementslog_warnings=1Long_query_time=0.25 #---------------Replicate--------------#relay-log-index =Relay3306.indexrelay-log =Relay3306server-ID= theInit_slave='Set Sql_mode=strict_all_tables'Log-slave-Updates[myisamchk]key_buffer=512msort_buffer_size=512mread_buffer=8mwrite_buffer=8m[mysql]prompt=mysql [\\d]>default-character-set=UTF8 [mysqlhotcopy]interactive-Timeout[mysqld_safe]open-files-limit =8192Log-error =/var/lib/mysql/Mysqld_error.logend
View Code
&NBSP;7: Generate a new image # Docker commit 64f075017f93 mysql:5.7.22 8: View Image # Docker imagesrepository tag image ID CREATED SIZEmysql 5.7.22 1bc73a7082d4 20 minutes ago 372mbmysql 5.7&nbSp 66bc0f66b7af & NBSP;&NBSP;2 weeks ago 372mb 9: Test whether the new mirror is in effect # Docker run-- Name Mysql_test -p 3306:3306-e mysql\_root\_password=123456 -d mysql:5.7.22# Docker exec-it mysql_test bash View/ETC/MYSQL/MY.CNF profile Host login Test MySQL database # mysql-uroot-p123456- h192.168.1.20
Docker repackaging MySQL5.7 Mirror