docker/cli · error
--format is incompatible with human friendly format
Error message
--format is incompatible with human friendly format
What it means
In `docker service inspect`, the `--pretty` and `--format` flags are mutually exclusive — `--pretty` selects the built-in human-readable template while `--format` selects a user-supplied Go template. This error fires at service/inspect.go:37-38 when both flags are set simultaneously (`opts.pretty == true && len(opts.format) > 0`). The check runs in the command's RunE before any API call is made.
Solutions
- Remove `--pretty` when using `--format` (they conflict by design)
- Remove `--format` when using `--pretty`
- Use `--format pretty` (exactly the word) instead of `--pretty` to get human-friendly output without the flag conflict
Example fix
# before
docker service inspect --pretty --format "{{.ID}}" myservice
# after (custom template)
docker service inspect --format "{{.ID}}" myservice
# after (human-friendly)
docker service inspect --pretty myservice Defensive patterns
Strategy: validation
Validate before calling
// Validate mutual exclusivity before invoking the command
func validateServiceInspectOpts(format string, pretty bool) error {
if pretty && len(format) > 0 {
return errors.New("--pretty and --format are mutually exclusive")
}
return nil
} Prevention
- Treat --pretty and --format as mutually exclusive in all wrapper scripts
- If you have a global --format alias, use `--format pretty` instead of --pretty to avoid the conflict path
- Document which output mode each script/alias uses to prevent accidental mixing
When it happens
Trigger: Running `docker service inspect --pretty --format "{{.ID}}" myservice` where both `--pretty` is true and `--format` has a non-empty value. Also triggered if a shell alias or wrapper always appends `--format` and the user adds `--pretty`.
Common situations: A developer has a Docker config or shell alias that sets `--format` globally, then tries to use `--pretty` for a quick human-readable check. Or a CI script hardcodes `--format json` and an operator overrides with `--pretty`.
Related errors
- cannot supply extra formatting options to the pretty…
- cannot supply extra formatting options to the pretty…
- tty service logs only supported with --raw
- placement preference must be of the format
- invalid credential spec: value must be prefixed with…
AI-assisted analysis of docker/cli@4f84911bfe (2026-08-07).
Data as JSON: /api/errors/5fe0ed38757de63a.
Report an issue: GitHub.
Appendix: source
Thrown at cli/command/service/inspect.go:38
type inspectOptions struct {
refs []string
format string
pretty bool
}
func newInspectCommand(dockerCLI command.Cli) *cobra.Command {
var opts inspectOptions
cmd := &cobra.Command{
Use: "inspect [OPTIONS] SERVICE [SERVICE...]",
Short: "Display detailed information on one or more services",
Args: cli.RequiresMinArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.refs = args
if opts.pretty && len(opts.format) > 0 {
return errors.New("--format is incompatible with human friendly format")
}
return runInspect(cmd.Context(), dockerCLI, opts)
},
ValidArgsFunction: completeServiceNames(dockerCLI),
DisableFlagsInUseLine: true,
}
flags := cmd.Flags()
flags.StringVarP(&opts.format, "format", "f", "", flagsHelper.InspectFormatHelp)
flags.BoolVar(&opts.pretty, "pretty", false, "Print the information in a human friendly format")
return cmd
}
func runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions) error {
apiClient := dockerCLI.Client()
if opts.pretty {View on GitHub (pinned to 4f84911bfe)