{"record":{"id":"6ca8e308fa07e93e","repo":"containerd/containerd","slug":"errnoshmmount","errorCode":"ErrNoShmMount","errorMessage":"no /dev/shm mount specified","messagePattern":"no /dev/shm mount specified","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/oci/spec_opts.go","lineNumber":1565,"sourceCode":"\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer f.Close()\n\n\t\tsc := bufio.NewScanner(f)\n\t\tfor sc.Scan() {\n\t\t\tvars = append(vars, sc.Text())\n\t\t}\n\t\tif err = sc.Err(); err != nil {\n\t\t\treturn err\n\t\t}\n\t\treturn WithEnv(vars)(nil, nil, nil, s)\n\t}\n}\n\n// ErrNoShmMount is returned when there is no /dev/shm mount specified in the config\n// and an Opts was trying to set a configuration value on the mount.\nvar ErrNoShmMount = errors.New(\"no /dev/shm mount specified\")\n\n// WithDevShmSize sets the size of the /dev/shm mount for the container.\n//\n// The size value is specified in kb, kilobytes.\nfunc WithDevShmSize(kb int64) SpecOpts {\n\treturn func(ctx context.Context, _ Client, _ *containers.Container, s *Spec) error {\n\t\tfor i, m := range s.Mounts {\n\t\t\tif filepath.Clean(m.Destination) == \"/dev/shm\" && m.Source == \"shm\" && m.Type == \"tmpfs\" {\n\t\t\t\tfor i := 0; i < len(m.Options); i++ {\n\t\t\t\t\tif strings.HasPrefix(m.Options[i], \"size=\") {\n\t\t\t\t\t\tm.Options = append(m.Options[:i], m.Options[i+1:]...)\n\t\t\t\t\t\ti--\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\ts.Mounts[i].Options = append(m.Options, fmt.Sprintf(\"size=%dk\", kb))\n\t\t\t\treturn nil\n\t\t\t}\n\t\t}","sourceCodeStart":1547,"sourceCodeEnd":1583,"githubUrl":"https://github.com/containerd/containerd/blob/4246446a2bf7d03837b0244118d858799393bd80/pkg/oci/spec_opts.go#L1547-L1583","documentation":"ErrNoShmMount is returned by opts like WithDevShmSize/WithDevShm when the generated Spec has no mount at /dev/shm for them to configure. These opts mutate the existing shm mount entry; without one there is nothing to act on.","triggerScenarios":"Calling oci.WithDevShmSize(kb) (or WithDevShm) as a SpecOpt when the Spec's Mounts slice contains no mount whose destination is /dev/shm.","commonSituations":"Custom Spec built by hand without the default /dev/shm mount; opts applied in the wrong order so no shm mount was added yet; running on configs derived from non-Linux templates.","solutions":["Add the shm mount before sizing it, e.g. ensure Spec.Mounts includes {Type: \"shm\", Source: \"shm\", Destination: \"/dev/shm\"}.","Use oci.WithDevShm (which adds the mount) before/instead of only WithDevShmSize.","Match with errors.Is(err, oci.ErrNoShmMount) and skip shm configuration for specs that legitimately have none."],"exampleFix":"// before\nopts := []oci.SpecOpts{oci.WithDevShmSize(65536)}\n// after\nopts := []oci.SpecOpts{oci.WithDevShm(65536)} // adds + sizes the /dev/shm mount","handlingStrategy":"try-catch","validationCode":"hasShm := false\nfor _, m := range spec.Mounts {\n    if filepath.Clean(m.Destination) == \"/dev/shm\" { hasShm = true }\n}\nif !hasShm { /* add shm mount before applying WithDevShmSize */ }","typeGuard":null,"tryCatchPattern":"if err := oci.WithDevShmSize(65536)(ctx, client, &ctr, &spec); err != nil {\n    if errors.Is(err, oci.ErrNoShmMount) { /* add mount or skip */ }\n}","preventionTips":["Use oci.WithDevShm to add the mount before sizing it","When building specs by hand, include the standard /dev/shm mount","Check spec.Mounts for /dev/shm in a pre-flight validator"],"tags":["oci","shm","mounts"],"backgroundTag":"missing-dev-shm-mount","analyzedSha":"4246446a2bf7d03837b0244118d858799393bd80","analyzedAt":"2026-09-02T00:14:43.053Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}