容器mysql安装访问

[root@corpse network-scripts]# docker pull  hub.c.163.com/library/mysql

[root@corpse network-scripts]# docker images

REPOSITORY                              TAG                 IMAGE ID            CREATED             SIZE
tomcat                                  v1                  64fd9afbf143        21 hours ago        648MB
test/spingboot1110                      latest              312eec2dd274        7 weeks ago         710MB
gsdx/agent                              tomcat9.0.39        960a15ca721d        8 weeks ago         711MB
tomcat                                  latest              35064a4fcc93        2 months ago        648MB
hello-world                             latest              bf756fb1ae65        12 months ago       13.3kB
sonamsamdupkhangsar/springboot-docker   latest              a0e068c5fa83        2 years ago         698MB
hub.c.163.com/library/mysql             latest              9e64176cd8a2        3 years ago         407MB
 

[root@corpse network-scripts]# docker history hub.c.163.com/library/mysql
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
9e64176cd8a2        3 years ago         /bin/sh -c #(nop)  CMD ["mysqld"]               0B
<missing>           3 years ago         /bin/sh -c #(nop)  EXPOSE 3306/tcp              0B
<missing>           3 years ago         /bin/sh -c #(nop)  ENTRYPOINT ["docker-entry…   0B
<missing>           3 years ago         /bin/sh -c ln -s usr/local/bin/docker-entryp…   34B
<missing>           3 years ago         /bin/sh -c #(nop) COPY file:5453fdbdb142b28e…   6.03kB
<missing>           3 years ago         /bin/sh -c #(nop)  VOLUME [/var/lib/mysql]      0B
<missing>           3 years ago         /bin/sh -c sed -Ei 's/^(bind-address|log)/#&…   1.23kB
<missing>           3 years ago         /bin/sh -c {   echo mysql-community-server m…   240MB
<missing>           3 years ago         /bin/sh -c echo "deb http://repo.mysql.com/a…   55B
<missing>           3 years ago         /bin/sh -c #(nop)  ENV MYSQL_VERSION=5.7.18-…   0B
<missing>           3 years ago         /bin/sh -c #(nop)  ENV MYSQL_MAJOR=5.7          0B
<missing>           3 years ago         /bin/sh -c set -ex;  key='A4A9406876FCBD3C45…   20.8kB
<missing>           3 years ago         /bin/sh -c apt-get update && apt-get install…   38.7MB
<missing>           3 years ago         /bin/sh -c mkdir /docker-entrypoint-initdb.d    0B
<missing>           3 years ago         /bin/sh -c set -x  && apt-get update && apt-…   4.58MB
<missing>           3 years ago         /bin/sh -c #(nop)  ENV GOSU_VERSION=1.7         0B
<missing>           3 years ago         /bin/sh -c groupadd -r mysql && useradd -r -…   330kB
<missing>           3 years ago         /bin/sh -c #(nop)  CMD ["/bin/bash"]            0B
<missing>           3 years ago         /bin/sh -c #(nop) ADD file:712c48086043553b8…   123MB

[root@corpse network-scripts]# docker run -itd  --name=mysql5718  -p 3309:3306 -v /data/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 hub.c.163.com/library/mysql
be5fa4444d5aa0cc5765de0fbfd025a6b470185acbe3030dc6e6e8c87ead4f5a
[root@corpse network-scripts]# docker ps
CONTAINER ID        IMAGE                         COMMAND                  CREATED             STATUS              PORTS                               NAMES
be5fa4444d5a        hub.c.163.com/library/mysql   "docker-entrypoint.s…"   4 seconds ago       Up 2 seconds        0.0.0.0:3309->3306/tcp              mysql5718
 

[root@corpse /]#mysql  -uroot -p123456 -h192.168.149.203  -P3309
mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.00 sec)

mysql> create database  cooldb
    -> ;
Query OK, 1 row affected (0.00 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| cooldb             |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.00 sec)

mysql> use cooldb;
Database changed
mysql> show tables ;
Empty set (0.00 sec)

mysql> create table  cool_z (id int(10),name varchar(10));
Query OK, 0 rows affected (0.00 sec)

mysql> insert into   cool_z (id,name) values(10,'co');
Query OK, 1 row affected (0.00 sec)

mysql> select * from cool_z;
+------+------+
| id   | name |
+------+------+
|   10 | co   |
+------+------+
1 row in set (0.00 sec)
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值