docker/cli · error
is not an absolute path
Error message
%s is not an absolute path
What it means
Thrown by validateLinuxPath when the resolved container path is not absolute (path.IsAbs returns false). The container-side path must start with '/'.
Solutions
- Prefix the container path with '/', e.g. /dev/sda1:/mnt/data
- Use an absolute path for the container destination
Example fix
# before docker run --device /dev/sda1:data ... # after docker run --device /dev/sda1:/data ...
Defensive patterns
Strategy: validation
Validate before calling
func validAbsContainerPath(spec string) error {
parts := strings.SplitN(spec, ":", 3)
containerPath := parts[len(parts)-1]
if len(parts) == 3 {
containerPath = parts[1]
}
if !filepath.IsAbs(containerPath) {
return fmt.Errorf("container path %q must be absolute", containerPath)
}
return nil
} Prevention
- Always construct container paths with a leading '/' in templates
When it happens
Trigger: Passing a relative path as the container destination, e.g. `--device /dev/sda1:relative/path` or `--mount` style with non-absolute container path. The check runs after path.Clean on the container path.
Common situations: Assuming the path is relative to the container's workdir; forgetting the leading slash; script interpolation that strips it.
Related errors
- bad format for path
- got a device
- unknown server OS
- invalid device specification
- invalid device cgroup format
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/19e0c96e535bcfab.
Report an issue: GitHub.
Appendix: source
Thrown at cli/command/container/opts.go:1128
if isValid := validator(split[1]); isValid {
containerPath = split[0]
mode = split[1]
val = fmt.Sprintf("%s:%s", path.Clean(containerPath), mode)
} else {
containerPath = split[1]
val = fmt.Sprintf("%s:%s", split[0], path.Clean(containerPath))
}
case 3:
containerPath = split[1]
mode = split[2]
if isValid := validator(split[2]); !isValid {
return val, fmt.Errorf("bad mode specified: %s", mode)
}
val = fmt.Sprintf("%s:%s:%s", split[0], containerPath, mode)
}
if !path.IsAbs(containerPath) {
return val, fmt.Errorf("%s is not an absolute path", containerPath)
}
return val, nil
}
// validateAttach validates that the specified string is a valid attach option.
func validateAttach(val string) (string, error) {
s := strings.ToLower(val)
if slices.Contains([]string{"stdin", "stdout", "stderr"}, s) {
return s, nil
}
return val, errors.New("valid streams are STDIN, STDOUT and STDERR")
}
func toNetipAddrSlice(ips []string) []netip.Addr {
if len(ips) == 0 {
return nil
}
netIPs := make([]netip.Addr, 0, len(ips))View on GitHub (pinned to 4f84911bfe)