标签:
1、安装docker,网上一堆,这里不细说。
2、进入linux后,使用docker命令下载mysql,命令如:
docker pull mysql:5.7
运行该命令后,则会显示以下日志:
5.7: Pulling from mysql
4c8cbfd2973e: Pull complete
60c52dbe9d91: Pull complete
c2b0136be90f: Pull complete
273cd71eacf0: Pull complete
543ff72402d8: Pull complete
f928e22e58b0: Pull complete
2d1023ecaed4: Pull complete
059dbbef4dd8: Pull complete
ac0ee0367a32: Pull complete
a9057a689e83: Pull complete
5191ddfc3b01: Pull complete
6e2ce31eb835: Pull complete
099dc92e9b15: Pull complete
7b4030a6b20b: Pull complete
fdb9c2185fc2: Already exists
mysql:5.7: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:d00f3f3cd30d0e8ad9bdf8ba61729ee1a4b6fe84a0fbb95f07dc2668a4cb5d08
Status: Downloaded newer image for mysql:5.7
下载需要一段时间,下载完毕后,启动docker容器。
3、先查看本机都有哪些镜像,命令如下:docker images
然后会打印出以下日志:
REPOSITORY TAG IMAGE ID CREATED VIRTUAL
SIZE
mysql 5.7 fdb9c2185fc2 9 days ago 321.9 MB
csphere/csphere 0.11.2 6d983828b938 8 weeks ago 112 MB
4、然后启动我们的mysql的docker容器,命令如下:
docker run --name db001 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=mytest -d mysql:5.7
注意,这里的容器名字叫:db001,mysql的root用户密码是:mytest,映射宿主机子的端口3306到容器的端口3306,仓库名mysql和标签(tag)唯一确定了要指定的镜像,其实如果这里只有一个mysql也有必要要tag,执行该命令返回的结果是:
a40c6e58afbda0199111a2a2ef0af7e8dd9be057a610ca5f4f30aa782a5d9155
5、查看已经运行的的所有容器,命令如:docker ps
返回的结果是:
CONTAINER ID IMAGE COMMAND CREATED
STATUS PORTS NAMES
a40c6e58afbd mysql:5.7 "/entrypoint.sh mysq 12 seconds ago Up 12 seconds 0.0.0.0:3306->3306/tcp db001
512013f5bd3a csphere/csphere:0.11.2 "/bin/csphere-init - 10 days ago Up 10 days csphere-agent
631a4f91b2fb csphere/csphere:0.11.2 "/bin/csphere-init - 10 days ago Up 10 days 8086/tcp, 27017/tcp, 0.0.0.0:1016->80/tcp csphere-controller
使用mysql的工具,比如navicat连接成功。
这里我们没有制作自己的镜像,直接使用了网上已有的,开始是从docker pull dl.dockerpool.com:5000/mysql:5.7路径上pull myql镜像,结果没有成功,所以直接使用了上边说的docker pull mysql:5.7,没有什么技术含量,给入门的同学用吧。
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:
原文地址:http://blog.csdn.net/achilles12345/article/details/47025903