简体   繁体   English

如何使用我的 gpg 密钥解密 docker 容器中的文件而不将其保存在图像中?

[英]How do I use my gpg key to decrypt a file in a docker container without saving it in the image?

I'm using airflow and the dockerOperator to connect to a docker daemon and spin up a container.我正在使用气流和 dockerOperator 连接到 docker 守护进程并启动一个容器。

As part of my pipeline this container needs to decrypt a file using gpg.作为我的管道的一部分,这个容器需要使用 gpg 解密文件。

If I copy the gpg key in during docker build then it will be apart of the image forever, this feels insecure?如果我在 docker build 期间复制 gpg 密钥,那么它将永远与图像分开,这感觉不安全吗?

I have investigated whether or not I can put the key into an environment variable and pass it in that way ie through dockers -e VAR:VAL syntax.我已经调查过我是否可以将密钥放入环境变量中并以这种方式传递它,即通过 dockers -e VAR:VAL语法。 The only other way I can think of is to mount my local .gnupg file into the container and use that, however this will only work while I'm on my local machine.我能想到的唯一另一种方法是将我的本地.gnupg文件挂载到容器中并使用它,但是这只在我在本地机器上时才有效。 I want to be able to migrate to ECS or kubernetes at some stage.我希望能够在某个阶段迁移到 ECS 或 kubernetes。

You are correct in saying, that adding the key during docker build is insecure.您说得对,在 docker build 期间添加密钥是不安全的。

The env var is a valid way. env var 是一种有效的方式。 If you use kubernetes later, you can safely save the your key as a secret in kubernetes.如果您以后使用 kubernetes,您可以安全地将您的密钥保存为 kubernetes 中的秘密。 When deploying you can provide a secret via env to a container.部署时,您可以通过 env 向容器提供机密。

You could also provide a secret as a file from a kubernetes secret by using a volume, and mount a volume locally and provide the key file.您还可以通过使用卷从 kubernetes 秘密中提供秘密作为文件,并在本地安装卷并提供密钥文件。

These are the official docs for kubernetes secrets: https://kubernetes.io/docs/concepts/configuration/secret/这些是 kubernetes 秘密的官方文档: https ://kubernetes.io/docs/concepts/configuration/secret/

I am not familiar with ECS, but I am positive that there are similar ways.我不熟悉 ECS,但我肯定有类似的方法。

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

相关问题 从 docker 容器内使用 gpg 解密 - Decrypt with gpg from inside a docker container 在Docker容器内非交互地解密gpg文件 - Decrypt gpg files non-interactively inside a Docker container 如何在加载 docker 容器而不运行 docker-compose 后运行它? - How do I run my docker container after loading it without running docker-compose up? 保存Docker容器映像 - Saving docker container image 如何让我的 Dreamweaver 站点使用我的 nginx docker 容器作为 Web 测试服务器? - How do I get my dreamweaver site to use my nginx docker container as a web test server? 如何使用 Jenkinsfile 将 Docker 映像部署到某个 Docker 容器? - How do i deploy a Docker image to a certain Docker container with a Jenkinsfile? 如何在Docker容器中使用'keyboard'python模块而不会出现错误? - How do I use the 'keyboard' python module in a docker container without an error? 如何将文件传递到 Docker 容器中以与容器一起使用? - How do I pass a file into a Docker container to be used with the container? 如何将 tesseract 添加到我的 Docker 容器中,以便我可以使用 pytesseract - How do I add tesseract to my Docker container so i can use pytesseract 如何将图像文件从我的桌面复制到 docker 容器 - How to copy image file from my desktop to docker container
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM