Docker容期卷安装MySQL

Docker安装MySQL

思考: MySQL数据持久化的问题!

# 获取镜像
docker pull mysql:5.7
5.7: Pulling from library/mysql
b4d181a07f80: Already exists 
a462b60610f5: Pull complete 
578fafb77ab8: Pull complete 
524046006037: Pull complete 
d0cbe54c8855: Pull complete 
aa18e05cc46d: Pull complete 
32ca814c833f: Pull complete 
52645b4af634: Pull complete 
bca6a5b14385: Pull complete 
309f36297c75: Pull complete 
7d75cacde0f8: Pull complete 
Digest: sha256:1a2f9cd257e75cc80e9118b303d1648366bc2049101449bf2c8d82b022ea86b7
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

# 查看mysql的镜像
docker images
REPOSITORY      TAG       IMAGE ID       CREATED         SIZE
tomcat          9.0       36ef696ea43d   4 days ago      667MB
tomcat          latest    36ef696ea43d   4 days ago      667MB
redis           latest    08502081bff6   13 days ago     105MB
nginx           latest    4f380adfc10f   13 days ago     133MB
mysql           5.7       09361feeb475   13 days ago     447MB
centos          latest    300e315adb2f   7 months ago    209MB
elasticsearch   7.6.2     f29a1ee41030   15 months ago   791MB

# 运行容器,需要做容器挂载。安装启动mysql需要设置密码
docker run -d -p 3306:3306 -v /Users/mac/mysql/conf:/etc/mysql/conf.d -v /Users/mac/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=mysql-secret-pw --name mysql01 mysql:5.7
544ecad1affbfe5ad47954905949ee6e0bfae84312465a97149d7ac8b4d04d97
## 参数说明: -d 后台运行 -p端口映射 -P随机映射端口 -v数据卷挂载 -e环境配置 --name容器名称

# 启动成功后, 我们本地使用客户端测试工具测试下

Docker容期卷安装MySQL

上一篇:Hadoop源码详解之DBOutputFormat类


下一篇:一条 sql 的执行过程详解