Skip to content

Commit

Permalink
add docs and unconfined to run a container without the default seccom…
Browse files Browse the repository at this point in the history
…p profile

Signed-off-by: Jessica Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Dec 28, 2015
1 parent a48fe62 commit 15674c5
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 5 deletions.
2 changes: 1 addition & 1 deletion daemon/execdriver/native/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (d *Driver) createContainer(c *execdriver.Command, hooks execdriver.Hooks)
container.AppArmorProfile = c.AppArmorProfile
}

if c.SeccompProfile != "" {
if c.SeccompProfile != "" && c.SeccompProfile != "unconfined" {
container.Seccomp, err = loadSeccompProfile(c.SeccompProfile)
if err != nil {
return nil, err
Expand Down
19 changes: 19 additions & 0 deletions docs/security/seccomp.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,22 @@ Then you can run with:
```
$ docker run --rm -it --security-opt seccomp:/path/to/seccomp/profile.json hello-world
```

Default Profile
---------------

The default seccomp profile provides a sane default for running
containers with seccomp. It is moderately protective while
providing wide application compatibility.


Overriding the default profile for a container
----------------------------------------------

You can pass `unconfined` to run a container without the default seccomp
profile.

```
$ docker run --rm -it --security-opt seccomp:unconfined debian:jessie \
unshare --map-root-user --user sh -c whoami
```
3 changes: 1 addition & 2 deletions hack/make/.ensure-userns-test
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ set -e
dir="$DEST/userns-test"
mkdir -p "$dir"
(
GOOS=${DOCKER_ENGINE_GOOS:="linux"}
if [ "$GOOS" = "linux" ]; then
if [ "$(go env GOOS)" = "linux" ]; then
cd "$dir"
gcc -g -Wall -static ../../../../contrib/userns-test/main.c -o ./userns-test
cp ../../../../contrib/userns-test/Dockerfile .
Expand Down
16 changes: 14 additions & 2 deletions integration-cli/docker_cli_run_unix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -598,8 +598,20 @@ func (s *DockerSuite) TestRunSeccompProfileDenyCloneUserns(c *check.C) {
}
}

// TestRunSeccompAllowPrivCloneUserns checks that 'docker run userns-test'
// with a the default seccomp profile exits with operation not permitted.
// TestRunSeccompUnconfinedCloneUserns checks that
// 'docker run --security-opt seccomp:unconfined userns-test' allows creating a userns.
func (s *DockerSuite) TestRunSeccompUnconfinedCloneUserns(c *check.C) {
testRequires(c, SameHostDaemon, seccompEnabled, NotUserNamespace)

// make sure running w privileged is ok
runCmd := exec.Command(dockerBinary, "run", "--security-opt", "seccomp:unconfined", "userns-test", "id")
if out, _, err := runCommandWithOutput(runCmd); err != nil || !strings.Contains(out, "nobody") {
c.Fatalf("expected clone userns with --security-opt seccomp:unconfined to succeed, got %s: %v", out, err)
}
}

// TestRunSeccompAllowPrivCloneUserns checks that 'docker run --privileged userns-test'
// allows creating a userns.
func (s *DockerSuite) TestRunSeccompAllowPrivCloneUserns(c *check.C) {
testRequires(c, SameHostDaemon, seccompEnabled, NotUserNamespace)

Expand Down

0 comments on commit 15674c5

Please sign in to comment.