docker创建mysql实例

[root@server1 hjl]# docker ps -a |grep mysql
fb0d1d56a395 mysql "docker-entrypoint.sh" 14 minutes ago Up 14 minutes 0.0.0.0:3306->3306/tcp mysql-2
fc4337de6716 hub.c.163.com/library/mysql "docker-entrypoint.sh" 15 minutes ago Up 15 minutes k8s_mysql.1a4722ab_mysql-kphr7_default_828d279b-8c50-11e7-b38e-000c29156886_a168e4ff
470e28607ba9 registry.access.redhat.com/rhel7/pod-infrastructure:latest "/pod" 15 minutes ago Up 15 minutes k8s_POD.1d520ba5_mysql-kphr7_default_828d279b-8c50-11e7-b38e-000c29156886_2d40c205
8bccbf191d39 mysql "docker-entrypoint.sh" 23 minutes ago Created mysql-1
7e07f0a2c4a8 mysql "docker-entrypoint.sh" 26 minutes ago Created first-mysql
b236c7741743 hub.c.163.com/library/mysql "docker-entrypoint.sh" 25 hours ago Exited (0) 21 minutes ago k8s_mysql.1a4722ab_mysql-kphr7_default_828d279b-8c50-11e7-b38e-000c29156886_bfec0b0a
ee3dd206f4e9 registry.access.redhat.com/rhel7/pod-infrastructure:latest "/pod" 25 hours ago Exited (0) 21 minutes ago k8s_POD.1d520ba5_mysql-kphr7_default_828d279b-8c50-11e7-b38e-000c29156886_5d2cdefa
[root@server1 hjl]# docker rm mysql-1
mysql-1
[root@server1 hjl]# docker rm first-mysql
first-mysql
[root@server1 hjl]# docker run --name mysql-1 -p 3307:3306 -e MYSQL\_ROOT\_PASSWORD=123456 -d mysql
db1d27f65ea3f45529ab0a363cbb6242b221d7b57bca602f26d1347f6ae50f2e
[root@server1 hjl]# /usr/local/mysql/bin/mysql -h192.168.253.135 -P3307 -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye

[root@server1 hjl]# docker run --name mysql-3 -p 3308:3306 -e MYSQL\_ROOT\_PASSWORD=123456 -d mysql
2974abef6e12e93043a240b74b86565ef42804aba0f69d2f76b5e6b2ea6cef35
[root@server1 hjl]# /usr/local/mysql/bin/mysql -h192.168.253.135 -P3308 -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.19 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> exit
Bye
[root@server1 hjl]# docker ps -a |grep mysql
2974abef6e12 mysql "docker-entrypoint.sh" 45 seconds ago Up 44 seconds 0.0.0.0:3308->3306/tcp mysql-3
db1d27f65ea3 mysql "docker-entrypoint.sh" 8 minutes ago Up 8 minutes 0.0.0.0:3307->3306/tcp mysql-1
fb0d1d56a395 mysql "docker-entrypoint.sh" 25 minutes ago Up 25 minutes 0.0.0.0:3306->3306/tcp mysql-2
fc4337de6716 hub.c.163.com/library/mysql "docker-entrypoint.sh" 25 minutes ago Up 25 minutes k8s_mysql.1a4722ab_mysql-kphr7_default_828d279b-8c50-11e7-b38e-000c29156886_a168e4ff
470e28607ba9 registry.access.redhat.com/rhel7/pod-infrastructure:latest "/pod" 25 minutes ago Up 25 minutes k8s_POD.1d520ba5_mysql-kphr7_default_828d279b-8c50-11e7-b38e-000c29156886_2d40c205
b236c7741743 hub.c.163.com/library/mysql "docker-entrypoint.sh" 25 hours ago Exited (0) 31 minutes ago k8s_mysql.1a4722ab_mysql-kphr7_default_828d279b-8c50-11e7-b38e-000c29156886_bfec0b0a
ee3dd206f4e9 registry.access.redhat.com/rhel7/pod-infrastructure:latest "/pod" 26 hours ago Exited (0) 32 minutes ago k8s_POD.1d520ba5_mysql-kphr7_default_828d279b-8c50-11e7-b38e-000c29156886_5d2cdefa
[root@server1 hjl]#