Skip to content

🖐️ How to set privileged=true for c.container.From("docker:dind")? #15183

Open

Description

@huhouhua

What happened? What did you expect to happen?

Question

I am trying to run a container using c.container.From("docker:bind") (or docker:dind) and need to configure it to run in privileged mode (privileged=true).

Could someone advise on the recommended way or API to enable privileged=true for this container in the Dagger SDK?

Context

  • **Dagger Version: registry.dagger.io/engine:v0.21.7
  • **SDK Language: v0.21.11
  • Code snippet:
container := dag.Container().From("docker:bind")

Activity

  1. gyanaranjans commented on Nov 17, 2026

    @gyanaranjans

    There's no container-level privileged option in Dagger. Privilege is set per command, through insecureRootCapabilities on withExec (also on asService, up and terminal). Its schema doc says it's "Like --privileged in Docker" (core/schema/container.go). experimentalPrivilegedNesting is a different flag: it gives the command access back to the Dagger engine, and isn't what dockerd needs.

    For docker:dind, Dagger's own dockerd module (toolchains/python-sdk-dev/dockerd/main.go) does it like this:

    dockerd := dag.Container().
    	From("docker:dind").
    	WithMountedCache("/var/lib/docker", dag.CacheVolume("docker-lib")).
    	WithExposedPort(2375).
    	WithExec([]string{
    		"dockerd",
    		"--host=tcp://0.0.0.0:2375",
    		"--host=unix:///var/run/docker.sock",
    		"--tls=false",
    	}, dagger.ContainerWithExecOpts{InsecureRootCapabilities: true}).
    	AsService()
    
    out, err := dag.Container().
    	From("docker:cli").
    	WithServiceBinding("docker", dockerd).
    	WithEnvVariable("DOCKER_HOST", "tcp://docker:2375").
    	WithExec([]string{"docker", "run", "--rm", "alpine", "echo", "hi"}).
    	Stdout(ctx)

    The engine allows the security.insecure entitlement by default. It only gets refused if your engine config turns insecureRootCapabilities off (engine/server/server.go).

    Disclosure: I build Tier2, an AI support engineer, and ran it on this issue. I checked the answer against the v0.21.7 source myself. The full investigation with every claim cited is here: https://tier2.dev/r/t2r_NE0wXoVg17HLnAzl8n9vZWoTxmQ_BAaS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions