启动在VMware中的Docker中的mysql

1. start VMware, then startup the centos kuber OS

2. use ssh tool connect to centos kuber os as root, and check iptables port, restart iptables if needed

iptables -L -n
v:显示详细信息,包括每条规则的匹配包数量和匹配字节数
x:在 v 的基础上,禁止自动单位换算(K、M)
n:只显示IP地址和端口号,不将ip解析为域名
  systemctl start iptables.service
  systemctl status iptables.service
  systemctl stop iptables.service

3. check and start mysql container

[root@localhost ~]# docker ps
CONTAINER ID        IMAGE                 COMMAND                  CREATED             STATUS              PORTS                                              NAMES
e39d8a6d7ec1        docker.io/mysql:5.7   "docker-entrypoint..."   10 days ago         Up 22 minutes       0.0.0.0:3307->3306/tcp, 0.0.0.0:32768->33060/tcp   sad_einstein
[root@localhost ~]# docker start e39d8a6d7ec1

4. once mysql container startup, login to Docker mysql image from centos kuber OS(local pc)

[root@localhost ~]# docker exec -it sad_einstein bash
root@e39d8a6d7ec1:/#

5. check and start mysql 

[root@localhost ~]# docker exec -it sad_einstein bash
root@e39d8a6d7ec1:/# service mysql status
[info] MySQL Community Server 5.7.29 is not running.


root@e39d8a6d7ec1:/# service mysql start
...
[info] MySQL Community Server 5.7.29 is started.


root@e39d8a6d7ec1:/# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.29 MySQL Community Server (GPL)


mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |

6. make sure the firewall policy is active(run these cmd IN centos kuber OS, NOT in docker mysql image)

systemctl status iptables.service

7. use windows mysql tool to connect to db

启动在VMware中的Docker中的mysql_第1张图片

你可能感兴趣的:(Docker,mysql)