标签:docker mysql
mysql 服务器是目前比较流行的开源数据库服务器,下面介绍如何使用docker来做一个mysql数据库服务
core@localhost ~/base $ docker pull dl.dockerpool.com:5000/mysql:5.7
Pulling repository dl.dockerpool.com:5000/mysql
e95cbb9f48ea: Download complete
511136ea3c5a: Download complete
5a7d9470be44: Download complete
feb755848a9a: Download complete
034656f0ad7b: Download complete
d30d97371f31: Download complete
06fcd079bef3: Download complete
2702d110a524: Download complete
d46d6a3cd040: Download complete
b6ce9f97ca75: Download complete
63c6cebccd5a: Download complete
b9e91c841f3b: Download complete
5bc8425e8dff: Download complete
2a35d8172e2d: Download complete
43279c8daf8e: Download complete
02c1bd631e20: Download complete
7ea4b0fe19cc: Download complete
core@localhost ~/base $ docker tag dl.dockerpool.com:5000/mysql:5.7 mysql:5.7
core@localhost ~/base $ docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
base/163 latest 468d347c06bc 5 hours ago 249.1 MB
dl.dockerpool.com:5000/mysql 5.7 e95cbb9f48ea 5 days ago 258.6 MB
mysql 5.7 e95cbb9f48ea 5 days ago 258.6 MB
core@localhost ~/base $ docker run --name db001 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=admin -d mysql:5.7
#上面这条语句启动了一个名字叫 db001 的容器,他的 root 密码是 admin,映射宿主主机的端口3306到容器的端口3306,这些都是手工指定的。
core@localhost ~/base $ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
fb4b9ab6a2ba dl.dockerpool.com:5000/mysql:5.7 "/entrypoint.sh mysq 2 seconds ago Up 2 seconds 0.0.0.0:3306->3306/tcp
这样我们就可以使用 mysql 服务器了,下一章将介绍如何开启 tomcat 容器 链接到这个 db001 的数据库容器
标签:docker mysql
原文地址:http://blog.csdn.net/smallfish1983/article/details/40080305