这一篇继续完善webnotebook,如果你读过上一篇的内容,你应该知道怎么去挂载webnotebook日志和容器的远程访问,但是这些还远不够,webnotebook
总要和一些数据库打交道吧,比如说MysqL,mongodb,redis,通常情况下这些存储设备要么是以容器的方式承载,要么是由DBA在非容器环境下统一管理。
一:webnotebook连接容器redis
我们做一个小案例,把网站的所有PV记录到redis中,webnotebook前端显示当前你是 xxx 位用户,案例不重要,重要的是怎么去实现容器互联。
在docker hub 上去找redis的官方镜像,具体redis该如何合理配置这里我就不管了,用最简单的一条docker run 跑起来再说。
@H_502_23@[root@localhost data]# docker run --name some-redis -d redis Unable to find image 'redis:latest' locally latest: Pulling from library/redis 6ae821421a7d: Pull complete e3717477b42d: Pull complete 8e70bf6cc2e6: Pull complete 0f84ab76ce60: Pull complete 0903bdecada2: Pull complete 492876061fbd: Pull complete Digest: sha256:dd5b84ce536dffdcab79024f4df5485d010affa09e6c399b215e199a0dca38c4 Status: Downloaded newer image for redis:latest ed07890700a5cdb7d737a196c28009a9d1b08de35f55d51f53c80e6cfe6ba199 [root@localhost data]# [root@localhost data]# [root@localhost data]# docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ed07890700a5 redis "docker-entrypoint.s…" About a minute ago Up About a minute 6379/tcp some-redis