Welcome 微信登录

首页 / 数据库 / MySQL / Linux的Docker上如何安装MySQL

1、安装Docker,可以参考下面的连接,这里不细说。Ubuntu 15.04下安装Docker  http://www.linuxidc.com/Linux/2015-07/120444.htmDocker安装应用(CentOS 6.5_x64) http://www.linuxidc.com/Linux/2014-07/104595.htm 在Ubuntu Trusty 14.04 (LTS) (64-bit)安装Docker http://www.linuxidc.com/Linux/2014-10/108184.htm Docker安装应用(CentOS 6.5_x64) http://www.linuxidc.com/Linux/2014-07/104595.htm Ubuntu 14.04安装Docker  http://www.linuxidc.com/linux/2014-08/105656.htm 阿里云CentOS 6.5 模板上安装 Docker http://www.linuxidc.com/Linux/2014-11/109107.htm 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 MB4、然后启动我们的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,执行该命令返回的结果是:a40c6e58afbda0199111a2a2ef0af7e8dd9be057a610ca5f4f30aa782a5d91555、查看已经运行的的所有容器,命令如: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,没有什么技术含量,给入门的同学用吧。配置 Docker 镜像下载的本地 mirror 服务  http://www.linuxidc.com/Linux/2015-07/120061.htm在 Docker 中使用 MySQL http://www.linuxidc.com/Linux/2014-01/95354.htmDocker 的详细介绍:请点这里
Docker 的下载地址:请点这里本文永久更新链接地址