首页 > 代码库 > docker安装mysql
docker安装mysql
公司要用docker,先测试一下。
# To install, run the following commands as root:
curl -fsSLO https://get.docker.com/builds/Linux/x86_64/docker-1.12.1.tgz && tar --strip-components=1 -xvzf docker-1.12.1.tgz -C /usr/local/bin
# Then start docker in daemon mode:
/usr/local/bin/dockerd &
检查安装是否成功
[root@vm6 ~]# docker version Client: Version: 1.12.1 API version: 1.24 Go version: go1.6.3 Git commit: 23cf638 Built: Thu Aug 18 17:52:38 2016 OS/Arch: linux/amd64 Server: Version: 1.12.1 API version: 1.24 Go version: go1.6.3 Git commit: 23cf638 Built: Thu Aug 18 17:52:38 2016 OS/Arch: linux/amd64
若输出了 Docker 的版本号,说明安装成功了
下载一个mysql的镜像
[root@vm6 apps]# docker pull mysql:5.7 5.7: Pulling from library/mysql 6a5a5368e0c2: Pull complete 0689904e86f0: Pull complete 486087a8071d: Pull complete 3eff318f6785: Pull complete 3df41d8a4cfb: Pull complete 1b4a00485931: Pull complete 0bab0b2c2630: Pull complete 264fc9ce512d: Pull complete e0181dcdbbe8: Pull complete 53b082fa47c7: Pull complete e5cf4fe00c4c: Pull complete Digest: sha256:966490bda4576655dc940923c4883db68cca0b3607920be5efff7514e0379aa7 Status: Downloaded newer image for mysql:5.7
启动mysql的docker容器
[root@vm6 ~]# docker run --name mysql001 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=xxxxxxxx -d mysql:5.7 d3e0171c5ec8a720f66e6fccde4c4033007e6b1b15fabb4fd06537f34fd85a42
查看已经运行的的所有容器
[root@vm6 ~]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES d3e0171c5ec8 mysql:5.7 "docker-entrypoint.sh" 9 minutes ago Up 9 minutes 0.0.0.0:3306->3306/tcp mysql001
连接
mysql -uroot -pxxxxxxxx -h192.168.1.201
本文出自 “刚刚出壳的小鸟” 博客,请务必保留此出处http://qhd2004.blog.51cto.com/629417/1860143
docker安装mysql
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。