hashicorp/nomad · error

invalid source, must be "" for tmpfs

Error message

invalid source, must be "" for tmpfs

What it means

When converting a Nomad mount block to a Docker mount, a mount of type "tmpfs" must have an empty source: tmpfs mounts are backed by in-memory storage, not a host path or named volume. The driver returns this error if a non-empty source is supplied for a tmpfs mount.

Source

Thrown at drivers/docker/config.go:631

	switch m.Type {
	case "volume":
		vo := m.VolumeOptions
		hm.VolumeOptions = &mount.VolumeOptions{
			NoCopy: vo.NoCopy,
			Labels: vo.Labels,
			DriverConfig: &mount.Driver{
				Name:    vo.DriverConfig.Name,
				Options: vo.DriverConfig.Options,
			},
		}
	case "bind":
		hm.BindOptions = &mount.BindOptions{
			Propagation: mount.Propagation(m.BindOptions.Propagation),
		}
	case "tmpfs":
		if m.Source != "" {
			return hm, fmt.Errorf(`invalid source, must be "" for tmpfs`)
		}
		hm.TmpfsOptions = &mount.TmpfsOptions{
			SizeBytes: m.TmpfsOptions.SizeBytes,
			Mode:      fs.FileMode(m.TmpfsOptions.Mode),
		}
	default:
		return hm, fmt.Errorf(`invalid mount type, must be "bind", "volume", "tmpfs": %q`, m.Type)
	}

	return hm, nil
}

type DockerVolumeOptions struct {
	NoCopy       bool                     `codec:"no_copy"`
	Labels       hclutils.MapStrStr       `codec:"labels"`
	DriverConfig DockerVolumeDriverConfig `codec:"driver_config"`
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Remove the source field from the tmpfs mount block.
  2. If you need a host path or named volume, change type to "bind" or "volume" instead of tmpfs.
  3. Verify the mount stanza only uses destination/target plus tmpfs_options for tmpfs mounts.

Example fix

// before
mount {
  type   = "tmpfs"
  source = "/data"
  target = "/cache"
}
// after
mount {
  type   = "tmpfs"
  target = "/cache"
  tmpfs_options {
    size = 64000000
  }
}
Defensive patterns

Strategy: validation

Validate before calling

for _, m := range mounts {
  if m.Type == "tmpfs" && m.Source != "" {
    return fmt.Errorf("mount %q: tmpfs must not set source", m.Target)
  }
}

Type guard

func validTmpfsMount(m Mount) bool { return m.Type != "tmpfs" || m.Source == "" }

Prevention

When it happens

Trigger: A job's mount block sets type = "tmpfs" but also sets source = "/path" (or any volume name).

Common situations: Users copy a bind-mount block and change only type to tmpfs, forgetting that tmpfs needs no source; or they intend a volume/bind mount and mistype the type.

Understand the failure class

Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/ac739f5abca64301. Report an issue: GitHub.