Repository navigation
Description
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 deniedSteps 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:
containerd/cmd/containerd/server/server.go
Lines 90 to 98 in a6fa1d7
| 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 | |
| } | |
| } |
containerd/pkg/shim/util_unix.go
Lines 76 to 90 in a6fa1d7
| 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
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsTodo
Activity
dosubot commentedon Jul 23, 2026
Hi, @AkihiroSuda. I'm Dosu, and I'm helping the containerd team manage their backlog and am marking this issue as stale.
Recap
/var/run/containerdeven whenroot,state, and the gRPC socket are configured to custom paths./var/run/containerdreferences in both the server and shim code./run/containerdmount.Next Steps
Thanks for your understanding and contribution.