大网数据广告活动
服务器运维问答

Is there a more secure way to pass variables to a docker container than via env

· 52CE 我爱测

I'm experimenting with docker containers. More precise, I use docker-compose . I need to pass variables to my container and use an .env file for that. While that works, it makes my wonder how secure it is. I mean every script lan…

问题原文

原帖链接 · moestly · CC BY-SA 3.0

I'm experimenting with docker containers. More precise, I use docker-compose. I need to pass variables to my container and use an .env file for that. While that works, it makes my wonder how secure it is. I mean every script language has access to env and therefore any hack in the runnning application could expose sensitive data stored in env. I want to store data like db passwords.

Inspired by salt, I am looking for a way to safely pass my variables into my application template before building the container, instead of passing them into the env of the container. How could one achieve this?

已采纳解答

原帖链接 · Miguel A. C. · CC BY-SA 3.0

There's an alternative using Docker Swarm called Docker secrets. A swarm allows you to have a cluster of docker engine nodes and you can create a one machine cluster if you wish. Basically you can use secrets that are stored in the Docker Swarm cluster that can be used when a service (a service will deploy tasks using containers in your cluster) is deployed in your cluster.

Docker secrets are explained here and you can even use them in your compose files. You have a nice example for your environment variables here.

I use docker secrets to store Amazon S3 credentials that are used inside my containers.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-12-17)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。