简体   繁体   English

在启动期间将本地文件添加到 docker 容器(不是构建阶段)

[英]Add local files to docker container during startup (not build stage)

We have a project with sensitive information, which cannot be added to docker image during building.我们有一个包含敏感信息的项目,在构建过程中无法将其添加到 docker 镜像中。

The Dockerfile is: Dockerfile 是:

FROM openjdk:11.0.12-jre-slim
COPY target/security.jar /security.jar
ENTRYPOINT ["java","-jar","/security.jar"]

And in project security we have certs folder with *.cer files.在项目安全性中,我们有包含 *.cer 文件的certs文件夹。

security/
   src/ -- source files
   certs/ -- .cer files
      test1.cer
      test2.cer
   Dockerfile

We cannot include this files into image because of it is sensitive information.我们不能将此文件包含在图像中,因为它是敏感信息。 And we tried do it during startup container:我们尝试在启动容器期间执行此操作:

docker run --entrypoint /bin/sh security -c 'cp certs/* certs/ && java -jar /security.jar' security:latest

But got the error:但是得到了错误:

cp: cannot stat 'certs/*': No such file or directory

Is there any way to fix this?有没有什么办法解决这一问题?

Maybe need look to Docker volumes?也许需要查看 Docker 卷? Some like:有些人喜欢:

docker run <your_args> -v certs:/certs security:latest

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

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