Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --security-opts options to allow user to customize container labels and apparmor profile #8299

Merged
merged 4 commits into from
Oct 1, 2014

Conversation

vieux
Copy link
Contributor

@vieux vieux commented Sep 30, 2014

Replace #7425

rhatdan and others added 2 commits September 30, 2014 00:06
…guration

security-opts will allow you to customise the security subsystem.

For example the labeling system like SELinux will run on a container.

    --security-opt="label:user:USER"   : Set the label user for the container
    --security-opt="label:role:ROLE"   : Set the label role for the container
    --security-opt="label:type:TYPE"   : Set the label type for the container
    --security-opt="label:level:LEVEL" : Set the label level for the container
    --security-opt="label:disabled"    : Turn off label confinement for the container

Since we are passing a list of string options instead of a space separated
string of options, I will change function calls to use InitLabels instead of
GenLabels.  Genlabels interface is Depracated.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Signed-off-by: Victor Vieux <vieux@docker.com>
@vieux
Copy link
Contributor Author

vieux commented Sep 30, 2014

ping @rhatdan tell me how to fix the tests, they aren't working right now. ps -Z doesn't work on busybox and the tests aren't even failing.

## Using alternative security labeling

If you want to use the same label for multiple containers, you can override use
the security-opt flag to select an MCS level. This is a common practive for MLS
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/practive/practice?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@rhatdan
Copy link
Contributor

rhatdan commented Sep 30, 2014

@vieux I just figured this out. Basically since the tests are running docker in docker, SELinux thinks it is disabled, so the plabel returns "" and the tests are never run. I did change the tests to use cat /proc/self/attr/current rather then ps -eZ. But the tests will never run.

The only way to get the processes within a docker container to think SELinux is enabled would be to volume mount the /sys/fs/selinux into the container.

Not really a good way to do this, So maybe I should drop the tests. Or just document the fact that if selinux was enabled in the test container these tests would run.

@vieux
Copy link
Contributor Author

vieux commented Sep 30, 2014

@rhatdan I think we should drop the tests, @crosbymichael ?

Signed-off-by: Victor Vieux <vieux@docker.com>
@crosbymichael
Copy link
Contributor

I would say drop the integration tests and write unit tests for the parsing of these settings

@vieux
Copy link
Contributor Author

vieux commented Sep 30, 2014

ok, @rhatdan I'll take care of it

Signed-off-by: Victor Vieux <vieux@docker.com>
@crosbymichael crosbymichael added this to the 1.3.0 milestone Sep 30, 2014
@crosbymichael
Copy link
Contributor

ping @jfrazelle @erikh @aluzzardi please review

@aluzzardi
Copy link
Member

LGTM

1 similar comment
@jessfraz
Copy link
Contributor

jessfraz commented Oct 1, 2014

LGTM

@aluzzardi
Copy link
Member

We need docs review.

Ping @jamtur01 @fredlf @SvenDowideit @ostezer

@crosbymichael
Copy link
Contributor

Docs were reviewed in the previous PR

aluzzardi added a commit that referenced this pull request Oct 1, 2014
Add --security-opts options to allow user to customize container labels and apparmor profile
@aluzzardi aluzzardi merged commit d40ab6f into moby:master Oct 1, 2014
@vieux vieux deleted the pr_7425 branch October 1, 2014 00:53
@rhatdan
Copy link
Contributor

rhatdan commented Oct 1, 2014

I rewrote some of the description of the --security-opt options.

Using alternative security labeling

You can override the default labeling scheme for each container by specifying
the --security-opt flag. For example you can specify the MCS/MLS level, a
requirement for MLS systems. Specifing the level in the following command
allows you to share the same content between containers.

# docker run --security-opt label:level:s0:c100,c200 -i -t fedora bash

An MLS example might be.

# docker run --security-opt label:level:TopSecret -i -t rhel7 bash

If you want to disable the security labeling but do not want to disable all
security by using the --permissive flag you can use the following command.

# docker run --security-opt label:disable -i -t fedora bash

If you decide you would like to work with a tighter policy on your container,
you can specify an alternate type for the container. For example if you want to
run a container that could only listen on apache ports, and not connect to the
network, execute the following command.

# docker run --security-opt label:type:svirt_apache_t -i -t centos bash

Note: You would have to write policy defining a svirt_apache_t type.

@vieux
Copy link
Contributor Author

vieux commented Oct 1, 2014

@rhatdan can you make a PR ?

@rhatdan
Copy link
Contributor

rhatdan commented Oct 3, 2014

I did.

#8384

@vieux
Copy link
Contributor Author

vieux commented Oct 3, 2014

Thank you @rhatdan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants