docker:security:don_t_leak_sensitive_information_to_docker_images
This is an old revision of the document!
Docker - Security - Don’t leak sensitive information to docker images
It’s easy to accidentally leak secrets, tokens, and keys into images when building them.
To stay safe, follow these guidelines:
- Use multi-stage builds.
- Use the Docker secrets feature to mount sensitive files without caching them (supported only from Docker 18.04).
- Use a .dockerignore file to avoid a hazardous COPY instruction, which pulls in sensitive files that are part of the build context.
Sometimes, when building an application inside a Docker image, you need secrets such as an SSH private key to pull code from a private repository, or you need tokens to install private packages.
If you copy them into the Docker intermediate container they are cached on the layer to which they were added, even if you delete them later on.
These tokens and keys must be kept outside of the Dockerfile.
docker/security/don_t_leak_sensitive_information_to_docker_images.1587240057.txt.gz · Last modified: 2020/07/15 09:30 (external edit)