简体   繁体   English

如何将 Redis 运行到多阶段 Docker 映像构建中?

[英]How to run Redis into multi-stage Docker image build?

I am doing a small Proof of Concept and want to run the Spring Boot application with Redis into the same container.我正在做一个小的概念证明,并希望将Spring Boot应用程序与Redis一起运行到同一个容器中。

I found multi-stage build docs and official Redis image .我找到了多阶段构建文档官方 Redis 图像

How should I connect them together?我应该如何将它们连接在一起? Even the concept seems to be for couple of years, I still cannot find relevant examples.即使这个概念似乎已经存在了几年,我仍然找不到相关的例子。

My Dockerfile :我的Dockerfile

FROM redis:5.0.6-alpine

// How can I run Redis server in here?

FROM openjdk:8-jdk-alpine
VOLUME /tmp
EXPOSE 9001
ARG DEPENDENCY=target/dependency
COPY ${DEPENDENCY}/BOOT-INF/lib /app/lib
COPY ${DEPENDENCY}/META-INF /app/META-INF
COPY ${DEPENDENCY}/BOOT-INF/classes /app
ENTRYPOINT ["java","-cp","app:app/lib/*","name.poc.Application"]

You can follow the docs您可以关注文档

But, the docs explicitly state:但是,文档明确 state:

It is generally recommended that you separate areas of concern by using one service per container.通常建议您通过每个容器使用一项服务来分隔关注区域。

So it's better to have 2 docker containers or docker swarm services in your case:因此,在您的情况下,最好有 2 个 docker 容器或 docker 群服务:

redis and java app. redis 和 java 应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM