docker/cli · error
type is empty: must be one of
Error message
type is empty: must be one of "%s"
What it means
Returned by 'docker inspect' when --type is explicitly set but its value is empty (e.g. --type ''). The command requires a non-empty value drawn from the supported object types when the flag is present.
Solutions
- Provide a concrete type from: container, image, network, node, plugin, secret, service, task, volume (or config).
- If you don't want to filter by type, omit --type entirely.
- Validate the variable is non-empty before passing it.
Example fix
# before OBJ_TYPE="" docker inspect --type "$OBJ_TYPE" myid # after OBJ_TYPE=container docker inspect --type "$OBJ_TYPE" myid # -or- omit the flag docker inspect myid
Defensive patterns
Strategy: validation
Validate before calling
// Reject empty --type when the flag is present
if cmd.Flags().Changed("type") && opts.objectType == "" {
return errors.New("--type must not be empty")
} Type guard
func nonEmptyType(s string) bool {
return strings.TrimSpace(s) != ""
} Prevention
- Default unset variables before passing to --type.
- Omit --type when filtering is unnecessary.
- Validate against the supported type list.
When it happens
Trigger: Running 'docker inspect --type "" <id>' or passing an empty --type from a script/variable. The guard at inspect.go:68-70 checks flags.Changed("type") && opts.objectType == "".
Common situations: Shell variable expanded to empty ('$OBJ_TYPE' unset); typo '--type=' with nothing after; template/script bug feeding an empty type.
Related errors
- unknown type: : must be one of
- other flags may not be combined with --rollback
- specify only one -H
- `-- ` flag requires the `--rotate` flag to update the CA
- error: no such object
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/3a1e7fe819dd998c.
Report an issue: GitHub.
Appendix: source
Thrown at cli/command/system/inspect.go:69
type inspectOptions struct {
format string
objectType objectType
size bool
ids []string
}
// newInspectCommand creates a new cobra.Command for `docker inspect`
func newInspectCommand(dockerCLI command.Cli) *cobra.Command {
var opts inspectOptions
cmd := &cobra.Command{
Use: "inspect [OPTIONS] NAME|ID [NAME|ID...]",
Short: "Return low-level information on Docker objects",
Args: cli.RequiresMinArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.ids = args
if cmd.Flags().Changed("type") && opts.objectType == "" {
return fmt.Errorf(`type is empty: must be one of "%s"`, strings.Join(allTypes, `", "`))
}
return runInspect(cmd.Context(), dockerCLI, opts)
},
// TODO(thaJeztah): should we consider adding completion for common object-types? (images, containers?)
ValidArgsFunction: completeObjectNames(dockerCLI),
DisableFlagsInUseLine: true,
}
flags := cmd.Flags()
flags.StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp)
flags.StringVar(&opts.objectType, "type", "", "Only inspect objects of the given type")
flags.BoolVarP(&opts.size, "size", "s", false, "Display total file sizes if the type is container")
_ = cmd.RegisterFlagCompletionFunc("type", completion.FromList(allTypes...))
return cmd
}
View on GitHub (pinned to 4f84911bfe)