Docker-安装Mysql8.x
1、搜索mysql的docker镜像(默认PC已经安装好了Docker)
lixianshengdeMacBook-Pro:~ lixiansheng$ docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11937 [OK]
mariadb MariaDB Server is a high performing open sou… 4562 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Create… 896 [OK]
percona Percona Server is a fork of the MySQL relati… 567 [OK]
phpmyadmin phpMyAdmin - A web interface for MySQL and M… 417 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 92
mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 90
centurylink/mysql Image containing mysql. Optimized to be link… 59 [OK]
databack/mysql-backup Back up mysql databases to... anywhere! 54
prom/mysqld-exporter 46 [OK]
deitch/mysql-backup REPLACED! Please use http://hub.docker.com/r… 41 [OK]
tutum/mysql Base docker image to run a MySQL database se… 35
linuxserver/mysql A Mysql container, brought to you by LinuxSe… 34
schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 31 [OK]
mysql/mysql-router MySQL Router provides transparent routing be… 23
centos/mysql-56-centos7 MySQL 5.6 SQL database server 21
arey/mysql-client Run a MySQL client from a docker container 20 [OK]
fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron tas… 18 [OK]
openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6
ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 3 [OK]
devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offici… 3
idoall/mysql MySQL is a widely used, open-source relation… 3 [OK]
jelastic/mysql An image of the MySQL database server mainta… 2
centos/mysql-80-centos7 MySQL 8.0 SQL database server 2
widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl… 1 [OK]
2、获取镜像
docker pull mysql
3、查看获取到的镜像
lixianshengdeMacBook-Pro:~ lixiansheng$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql latest 3218b38490ce 2 weeks ago 516MB
4、运行容器
lixianshengdeMacBook-Pro:~ lixiansheng$ docker run -itd --name docker-mysql -p 3306:3306 --privileged=true -e MYSQL_ROOT_PASSWORD=123456 -v ~/Docker/mysql/conf:/etc/mysql/conf.d -v ~/Docker/mysql/logs:/logs -v ~/Docker/mysql/data:/var/lib/mysql
--privileged=true 获取临时的selinux的权限
-v 宿主机目录挂在到容器的地址,映射
-e MYSQL_ROOT_PASSWORD 初始化密码
5、查看容器的进程
lixianshengdeMacBook-Pro:~ lixiansheng$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 3a70c32b4525 mysql "docker-entrypoint.s…" 26 seconds ago Up 25 seconds 0.0.0.0:3306->3306/tcp, 33060/tcp docker-mysql
相关命令
1、进入容器 docker exec -it (容器id或者容器名) /bin/bash
2、进入容器后 vim 没有此命令,进行安装 apt-get update, apt-get install vim
3、金融容器后ping 没有此命令,进行安装 apt-get update, apt-get install iputils-ping
参考:
https://blog.csdn.net/zgpeace/article/details/104100413
https://www.jianshu.com/p/6544ca584ee6