1.拉取合适版本的镜像
[root@VM-0-17-centos ~]
5.7.31: Pulling from library/mysql
bf5952930446: Already exists
8254623a9871: Pull complete
938e3e06dac4: Pull complete
ea28ebf28884: Pull complete
f3cef38785c2: Pull complete
894f9792565a: Pull complete
1d8a57523420: Pull complete
5f09bf1d31c1: Pull complete
1b6ff254abe7: Pull complete
74310a0bf42d: Pull complete
d398726627fd: Pull complete
Digest: sha256:da58f943b94721d46e87d5de208dc07302a8b13e638cd1d24285d222376d6d84
Status: Downloaded newer image for mysql:5.7.31
docker.io/library/mysql:5.7.31
2.启动docker,配置数据卷
[root@VM-0-17-centos ~]
Unable to find image 'mysql:latest' locally
latest: Pulling from library/mysql
bf5952930446: Already exists
8254623a9871: Already exists
938e3e06dac4: Already exists
ea28ebf28884: Already exists
f3cef38785c2: Already exists
894f9792565a: Already exists
1d8a57523420: Already exists
6c676912929f: Pull complete
ff39fdb566b4: Pull complete
fff872988aba: Pull complete
4d34e365ae68: Pull complete
7886ee20621e: Pull complete
Digest: sha256:c358e72e100ab493a0304bda35e6f239db2ec8c9bb836d8a427ac34307d074ed
Status: Downloaded newer image for mysql:latest
dfb00e6b835dbc5632337fc59954b164f5c07856f40b5371c39425f9f45f3b09
3.运行mysql
[root@VM-0-17-centos ~]
49a449d43748e919430fcbb17cd4d02d6fd1369973108f52c5ebcf411a49eddc