Description
Use security_opt to declare the runtime protections a service needs in addition to the Docker host’s defaults.
Potential impact
Host defaults vary. A service may have seccomp or AppArmor protection and still lack an option its deployment requires.
Remediation
Check the host’s active profiles. Declare the required options, such as no-new-privileges, AppArmor or SELinux, and keep environment-specific settings in the appropriate Compose file.
Examples
Replace sample/webapp:latest with your image and confirm the host supports the selected option.
Before
services:
webapp:
image: sample/webapp:latest
ports:
- "8080:8080"
After
services:
webapp:
image: sample/webapp:latest
ports:
- "8080:8080"
security_opt:
- no-new-privileges:true
The example adds no-new-privileges:true. A program keeps its existing privileges and cannot gain more through setuid or file capabilities when it executes another program.