基于Dockerfile构建Nginx、Tomcat、MySQL镜像(含包源)(3)

宿主机系统安装mariadb服务来测试

[root@localhost mysql5.7]# yum install mariadb -y [root@localhost mysql5.7]# mysql -h 20.0.0.149 -P 32774 -uroot -p123456 Welcome to the MariaDB monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.20 Source distribution Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MySQL [(none)]> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.01 sec) #创建一个数据库,退出后再次然后进入容器查看 MySQL [(none)]> create database mydb; Query OK, 1 row affected (0.00 sec) MySQL [(none)]> exit Bye [root@localhost mysql5.7]# docker exec -it mysql_new /bin/bash [root@e9c9f93766d1 mysql]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 5 Server version: 5.7.20 Source distribution Copyright (c) 2000, 2017, 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> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mydb | | mysql | | performance_schema | | sys | +--------------------+ 5 rows in set (0.00 sec) mysql> exit Bye [root@e9c9f93766d1 mysql]# exit exit [root@localhost mysql5.7]# 小结

基于Dockerfile构建这三个服务的镜像案例就说到这里,当然在工程中一般不会将MySQL服务放在容器中运行,而是会单独使用服务器部署提供服务(搭建高可用集群架构),本文主要是提供基于Dockerfile构建编写这些服务的案例。

需要注意两点:在Dockerfile中什么时候使用tar命令;权限问题

谢谢阅读!

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/cb21bace7d29368909aced018dc61c44.html