Skip to content

[macOS rootless] mkdir /var/run/containerd: permission denied even with custom state dir specified in config.toml #12444

Open

Description

@AkihiroSuda

Description

containerd fails with mkdir /var/run/containerd: permission denied, even with custom state dir specified in config.toml

$ whoami
suda

$ cat config.toml 
version = 3
root = '/Users/suda/containerd/lib/containerd'
state = '/Users/suda/containerd/run/containerd'
[grpc]
  address = '/Users/suda/containerd/run/containerd/containerd.sock'

$ containerd -c config.toml 
containerd: mkdir /var/run/containerd: permission denied

Steps to reproduce the issue

See above

Describe the results you received and expected

Received: mkdir /var/run/containerd: permission denied
Expected: no error

What version of containerd are you using?

containerd github.com/containerd/containerd/v2 v2.2.0-rc.0 870bb7c

Any other relevant information

Host: macOS 26.0.1 (ARM)

Show configuration if it is related to CRI plugin.

No response


The path is hard-coded here:

if config.State != defaults.DefaultStateDir {
// XXX: socketRoot in pkg/shim is hard-coded to the default state directory.
// See https://github.com/containerd/containerd/issues/10502#issuecomment-2249268582 for why it's set up that way.
// The default fifo directory in pkg/cio is also configured separately and defaults to the default state directory instead of the configured state directory.
// Make sure the default state directory is created with the correct permissions.
if err := sys.MkdirAllWithACL(defaults.DefaultStateDir, 0o711); err != nil {
return err
}
}

const socketRoot = defaults.DefaultStateDir
// SocketAddress returns a socket address
func SocketAddress(ctx context.Context, socketPath, id string, debug bool) (string, error) {
ns, err := namespaces.NamespaceRequired(ctx)
if err != nil {
return "", err
}
path := filepath.Join(socketPath, ns, id)
if debug {
path = filepath.Join(path, "debug")
}
d := sha256.Sum256([]byte(path))
return fmt.Sprintf("unix://%s/%x", filepath.Join(socketRoot, "s"), d), nil
}

Rootless mode on Linux does not suffer from this issue, as it mounts a new instance of /run/containerd in User+Mount namespaces
https://github.com/containerd/nerdctl/blob/c3dd63fe0fb8cf594704cb9d48b228bcca88f24c/extras/rootless/containerd-rootless.sh#L174-L176

Activity

  1. dosubot commented on Jul 23, 2026

    @dosubot

    Hi, @AkihiroSuda. I'm Dosu, and I'm helping the containerd team manage their backlog and am marking this issue as stale.

    Recap

    • You reported that on macOS rootless, containerd still tries to create /var/run/containerd even when root, state, and the gRPC socket are configured to custom paths.
    • The failure appears to come from hard-coded /var/run/containerd references in both the server and shim code.
    • You noted that Linux rootless avoids this by using a separate /run/containerd mount.
    • There hasn’t been any follow-up discussion or fix recorded in the issue comments yet.

    Next Steps

    • Please let us know if this is still relevant on the latest version of containerd.
    • If it is still reproducible, you can keep the discussion open by commenting here; otherwise, this issue will be automatically closed in 7 days.

    Thanks for your understanding and contribution.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions