ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
>[info] 构建 redis 镜像 * **编写Dockerfile代码:** ~~~console FROM alpine:3.12 RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \ && apk add gcc g++ libc-dev wget vim openssl-dev make linux-headers \ && rm -rf /var/cache/apk/* #通过选择更小的镜像,删除不必要文件清理不必要的安装缓存,从而瘦身镜像 COPY ./redis-6.0.9.tar.gz redis-6.0.9.tar.gz #创建相关目录能够看到日志信息跟数据跟配置文件 sh RUN mkdir -p /usr/src/redis \ && mkdir -p /redis/data \ && mkdir -p /redis/conf \ && mkdir -p /redis/log \ && mkdir -p /var/log/redis \ && tar -zxvf redis-6.0.9.tar.gz -C /usr/src/redis \ && rm -rf redis-6.0.9.tar.gz \ && cd /usr/src/redis/redis-6.0.9 && make \ && cd /usr/src/redis/redis-6.0.9 && make install; EXPOSE 6379 ENTRYPOINT ["redis-server"] #CMD ["redis-server","/usr/src/redis/redis-6.0.9/redis.conf"] CMD ["/redis/conf/redis.conf"] ~~~ ![](https://img.kancloud.cn/80/44/8044c1fb6748bf13acfb1a9fbe765637_2130x1051.png) * **构建镜像:** ``` docker build -f Dockerfile -t redis . ``` ![](https://img.kancloud.cn/ca/fb/cafbaccce9bef8f478d78416635d31e8_954x112.png) * **运行容器:** ``` docker run -itd --name redis -p 6379:6379 -v /home/docker/redis/output/conf/redis.conf:/home/redis/redis.conf redis redis-server /home/redis/redis.conf ```