操做系統:Mac OS X 參考文檔:https://hub.docker.com/_/mysql/mysql
https://hub.docker.com/
docker search mysql
本實例中拉取mysql 8.0版本的鏡像sql
docker pull mysql:8.0
docker images
mkdir -p ~/docker/mysql
docker run -p 3306:3306 --name mysql -v ~/docker/mysql/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=19901221 -d mysql:8.0
命令說明:docker
docker ps
docker exec -ti mysql /bin/bash
mysql -u root -p
若不修改密碼可能會出現遠程的mysql客戶端鏈接mysql容器失敗的狀況。bash
alter user 'root'@'%' identified with mysql_native_password by '19901221';
至此完成。ide