I have a container with alpine image (docker:dind) and I want to install ApparMor inside it to see how it works before I put it on the host.

I found ApparMor package in alpine repostiroy but I don't understand how to install it.

How can I install it and start using it?

On Ubuntu I succeeded with:
apt-get update && apt-get install apparmor-utils

But when I tried on alpine with: apk update && apk add apparmor-utils
It failed:

/ # apk update && apk add apparmor-utils
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
v3.8.2-19-g151c2021d6 [http://dl-cdn.alpinelinux.org/alpine/v3.8/main]
v3.8.2-18-gd7f33f856a [http://dl-cdn.alpinelinux.org/alpine/v3.8/community]
OK: 9546 distinct packages available
ERROR: unsatisfiable constraints:
  apparmor-utils (missing):
    required by: world[apparmor-utils]
  • 1
    Alpine has its own repository, and often names can be a bit different: pkgs.alpinelinux. So looks likeapk add apparmor should do the trick. Side note: looks like this is in the test repository. Most likely you need to add that to /etc/apk/repositories. sudo echo 'http://nl.alpinelinux.org/alpine/edge/testing' >> /etc/apk/repositories && sudo apk update && sudo info apparmor – rowan Jan 11 at 10:22
  • Good practice for test repositories is pinning, check out the documentation here and search for Repository pinning. In this case you won't just upgrade packages that you rather not want from testing. So be aware that I can screw up your installation based on my previous comment where I just echo the repository in without using pinning. – rowan Jan 11 at 10:29
  • @rowan I am running the alpine inside a container so I don't care if something will happen. I tried your first suggestion and it failed on info apparmor: sh: appramor: not found – E235 Jan 11 at 16:42
  • Did you add the repository? I just tested it, and it worked. – rowan Jan 11 at 17:25
  • It seems to be installed but the command ` info apparmor` is not working. I noticed I have a new command apparmor_parser. Does it mean that it installed? I thought I need to have a binary named apparmor. – E235 Jan 12 at 16:00

Thats because the name of the package is apparmor, not apparmor-utils. That "utils" thing at the end of the package name is Ubuntu specific and on Alpine, apparmor-utils is a subpackage.

Try to install the entire apparmor thing with apk update && apk add apparmor.

  • I am still getting the same error. I checked it on labs.play-with-docker.com. I started a container docker run -it alpine and then tried what you wrote. – E235 Jan 11 at 10:29

The package apparmor isn't available in the main repository. It can be installed from the testing repository, edge branch :

Add the following line to your /etc/apk/repositories (pinning way):

@edge http://dl-cdn.alpinelinux.org/alpine/edge/testing

Then run:

apk update
apk add apparmor@edge

Alpine Linux: Repository pinning

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.