在centos下 部署安装好docker后
搜索mysql的相关镜像
执行docker的搜索命令
1、docker search mysql
[root@localhost ~]# docker search mysql
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 8109 [OK]
mariadb MariaDB is a community-developed fork of MyS… 2750 [OK]
mysql/mysql-server Optimized MySQL Server Docker images. Create… 607 [OK]
zabbix/zabbix-server-mysql Zabbix Server with MySQL database support 190 [OK]
hypriot/rpi-mysql RPi-compatible Docker Image with Mysql 113
zabbix/zabbix-web-nginx-mysql Zabbix frontend based on Nginx web-server wi… 99 [OK]
centurylink/mysql Image containing mysql. Optimized to be link… 60 [OK]
centos/mysql-57-centos7 MySQL 5.7 SQL database server 52
1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5 ubuntu-16-nginx-php-phpmyadmin-mysql-5 50 [OK]
mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 44
tutum/mysql Base docker image to run a MySQL database se… 31
zabbix/zabbix-web-apache-mysql Zabbix frontend based on Apache web-server w… 29 [OK]
schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 26 [OK]
bitnami/mysql Bitnami MySQL Docker Image 26 [OK]
zabbix/zabbix-proxy-mysql Zabbix proxy with MySQL database support 22 [OK]
linuxserver/mysql A Mysql container, brought to you by LinuxSe… 20
centos/mysql-56-centos7 MySQL 5.6 SQL database server 13
mysql/mysql-router MySQL Router provides transparent routing be… 11
circleci/mysql MySQL is a widely used, open-source relation… 11
dsteinkopf/backup-all-mysql backup all DBs in a mysql server 6 [OK]
openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6
jelastic/mysql An image of the MySQL database server mainta… 1
cloudposse/mysql Improved `mysql` service with support for `m… 0 [OK]
widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl… 0 [OK]
ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 0 [OK]
[root@localhost ~]#
2、选择centos/mysql-57-centos7 镜像拉取下来
docker pull centos/mysql-57-centos7
[root@localhost ~]# docker pull centos/mysql-57-centos7
Using default tag: latest
latest: Pulling from centos/mysql-57-centos7
8ba884070f61: Already exists
c3dca185eb14: Pull complete
ee720ba20823: Pull complete
497ef6ea0fac: Pull complete
89a796eb6055: Pull complete
286c1dd3c000: Pull complete
89cd80e68683: Pull complete
e9b6c147b1a4: Pull complete
0d0097c10be8: Pull complete
Digest: sha256:8d750876687d9fb0adf46020e38cd43165b906208d2e81088b3a13213e751df3
Status: Downloaded newer image for centos/mysql-57-centos7:latest
3、启动centos/mysql-57-centos7 容器
其中
-p 端口映射 前者是宿主机的断货 后者是容器内的端口。
-e 这里是设置mysql的root账号的密码
docker run -di --name=mysql5.7 -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 centos/mysql-57-centos7
容器启动后 mysql服务就启动了
可以使用
docker ps 命令查看容器是否已经启动
因为做了端口映射 可以使用客户端工具 链接宿主机ip:3306 链接到mysql