docker安装mysql
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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 &
检查安装是否成功
[[email protected] ~]# 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的镜像
[[email protected] 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容器
[[email protected] ~]# docker run --name mysql001 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=xxxxxxxx -d mysql:5.7 d3e0171c5ec8a720f66e6fccde4c4033007e6b1b15fabb4fd06537f34fd85a42
查看已经运行的的所有容器
[[email protected] ~]# 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的主要内容,如果未能解决你的问题,请参考以下文章
Linux系统下祼机安装mysql8.0和docker mysql 8.0 性能差异对比~
Docker删除报错:Error response from daemon: conflict: unable to delete 08b152afcfae (must be forced)(代码片段