docker部署springBoot+mysql+redis
1.安装mysql
docker pull mysql:5.7
https://github.com/ChenXbFrank/springboot-mysql-redis-demo/ (下载代码即可)
配置文件根据docker环境配置的信息进行修改
2.将jar和dockerfile文件放到centos中的同一个文件夹,制作镜像
docker build -t [容器名] . 注意:后面有个点,表示当前目录下
3.docker运行mysql
4.安装redis
docker pull redis
docker run --name redis -p 6379:6379 -d redis redis-server --appendonly yes
redis-server --appendonly yes:在容器执行redis-server启动命令,并打开redis持久化配置
5.运行项目
docker run -it --net=host --name springboot_redis_demo -p 8088 springboot_redis_name (上面制作的容器名)
测试访问连接:http://192.168.3.201:8087/home/getAllList
从日志可以看出第一次读取的数据库里面的数据,第二次直接从redis缓存中获取的数据。
docker部署springboot+mysql+redis完成!(可以参考我的上篇博文https://blog.****.net/qq_33371766/article/details/105306238(docker部署springboot+mysql5.7))