Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker environment variable security

I have a docker application that I need to pass a secure piece of information to, since it uses a passphrase to encrypt/decrypt stored data. I'm trying to figure out how safe it is to use an environment variable to pass in this information. I know that if I use

docker run -e passphrase="secretkey123" --name containername imagename

Then the value can be found by:

docker inspect containername

Thus it must be stored somewhere on disk (in /var/lib/docker I assume). Is there any more secure way to pass an environment variable to docker? Should I use a temporary file in a volume linked to the host filesystem instead? Is there a better way?

like image 497
Jakob Weisblat Avatar asked Aug 06 '14 20:08

Jakob Weisblat


People also ask

Are Docker environment variables secure?

Developers often rely on environment variables to store sensitive data, which is okay for some scenarios but not recommended for Docker containers. Environment variables are even less secure than files. They are vulnerable in more ways, such as: Linked containers.

Are Docker containers a security risk?

Docker containers are, by default, quite secure; especially if you run your processes as non-privileged users inside the container. You can add an extra layer of safety by enabling AppArmor, SELinux, GRSEC, or another appropriate hardening system.

Can Docker container access environment variables?

When we launch our Docker container, we can pass environment variables as key-value pairs directly into the command line using the parameter –env (or its short form -e). As can be seen, the Docker container correctly interprets the variable VARIABLE1.


1 Answers

Regardless of where it is stored, it is clearly accessible via "docker inspect". I think it boils down to how secure you want it to be. For example, you can instead have a shared volume with file permissions to restrict access to a password file on disk. Or you could have a socker/ssh/etc to avoid putting the password into a file on disk at all. It just depends on how secure you really want to be.

I do note that if you have say a web server running in a container, I assume if someone breaks out of the web server they can only access what the container can access (and not the host OS where docker is running).

like image 194
Alan Kent Avatar answered Oct 05 '22 21:10

Alan Kent