How to configure Ubuntu AppArmor for Docker containers?

by wayne.swaniawski , in category: Security , 2 months ago

How to configure Ubuntu AppArmor for Docker containers?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by buster.gaylord , 21 days ago

@wayne.swaniawski 

To configure Ubuntu AppArmor for Docker containers, follow these steps:

  1. Install AppArmor on Ubuntu (if not already installed):
1
2
sudo apt-get update
sudo apt-get install apparmor-utils


  1. Add Docker AppArmor profiles:
1
sudo curl -o /etc/apparmor.d/docker https://raw.githubusercontent.com/moby/moby/master/contrib/apparmor/docker


  1. Load the Docker AppArmor profile:
1
sudo apparmor_parser -r /etc/apparmor.d/docker


  1. Now, you can specify AppArmor profiles in Docker containers. For example, if you want to run a container with the docker-default AppArmor profile, use the following command:
1
docker run --security-opt apparmor=docker-default <image-name>


Note: You can also create your own AppArmor profiles for Docker containers. For more information, see the Docker documentation on AppArmor profiles.