
Limiting container privileges
The principle used here is to provide the least privileges to perform a given task. When containers are run as root, they grant the user various privileges, such as installing packages or reading and writing the operating system. The risk is that if compromised, attackers can use privilege escalation while the container is running. There are two possible solutions to this. You can run containers in rootless mode or limit the capabilities of the LINUX kernel to only those necessary for the containers to run.
Secure Secret Management
Container and Docker configuration files should not contain secrets. Secrets include certificates, passwords, API keys, and tokens. While this is a best practice, it is common to see these secrets hardcoded during the build process or in source images. In such cases, sensitive data is leaked into containers and cached in intermediate container layers even after they are deleted. In such cases, it is best to deploy a secrets management solution such as AWS Secrets Manager and Vault to store and manage secret credentials.