Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Post History

50%
+0 −0
Q&A Can I confine an executable inside a Docker container using a host apparmor profile?

I'm trying to containerize an application that currently uses apparmor to confine Python. This allows sandboxing of user-submitted code. How can I get docker and apparmor to play well together? Cu...

0 answers  ·  posted 11mo ago by much‭

Question docker apparmor
#1: Initial revision by user avatar much‭ · 2023-12-15T21:50:47Z (11 months ago)
Can I confine an executable inside a Docker container using a host apparmor profile?
I'm trying to containerize an application that currently [uses apparmor to confine Python](https://github.com/openedx/codejail). This allows sandboxing of user-submitted code. How can I get docker and apparmor to play well together?

Current non-containerized setup:

- Create a `sandbox` system user
- Create a Python virtualenv with its own copy of the `python` binary
- Create and load an apparmor profile that only allows that `python` to access a couple of directories
- Run the user code as `sandbox`, using the confined `python`

It's easy to use `--security-opt apparmor=...` to confine an *entire* Docker container, but that doesn't keep user code separate from trusted application code within the container. I can even [target paths within the container's filesystem](https://securitylabs.datadoghq.com/articles/container-security-fundamentals-part-5/), but all of the *executables* in the container have the same confinement or lack thereof.

Is there a way to create an apparmor profile that says "/app/sandbox/python is only allowed to access /app/sandbox/data", with both of those paths relative to the container's filesystem?