[root@iZmu0fa4hv0jwzZ home]# docker pull mysql:5.7
[root@iZmu0fa4hv0jwzZ home]# docker run -d -p 3310:3306 -v /home/mysql/conf:/etc/mysql/conf.d -v /home/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 --name mysql01 mysql:5.7
[root@iZmu0fa4hv0jwzZ ~]# cd /home [root@iZmu0fa4hv0jwzZ home]# ls admin ceshi mysql [root@iZmu0fa4hv0jwzZ home]# cd mysql [root@iZmu0fa4hv0jwzZ mysql]# ls conf data [root@iZmu0fa4hv0jwzZ mysql]# cd data [root@iZmu0fa4hv0jwzZ data]# ls auto.cnf ca.pem client-key.pem ibdata1 ib_logfile1 mysql private_key.pem server-cert.pem sys ca-key.pem client-cert.pem ib_buffer_pool ib_logfile0 ibtmp1 performance_schema public_key.pem server-key.pem
说明挂载成功
删除MySql容器
[root@iZmu0fa4hv0jwzZ home]# docker rm -f mysql01 mysql01
查看主机上的MySQL文件
[root@iZmu0fa4hv0jwzZ home]# ls mysql/data auto.cnf ca.pem client-key.pem ibdata1 ib_logfile1 mysql private_key.pem server-cert.pem sys ca-key.pem client-cert.pem ib_buffer_pool ib_logfile0 ibtmp1 performance_schema public_key.pem server-key.pem
发现主机上的MySQL文件依然存在