description | keywords | title |
---|---|---|
CLI and log output formatting reference |
format, formatting, output, templates, log |
Format command and log output |
Docker uses Go templates which allow users to manipulate the output format of certain commands and log drivers. Each command a driver provides has a detailed list of elements they support in their templates:
- Docker Images formatting
- Docker Inspect formatting
- Docker Log Tag formatting
- Docker Network Inspect formatting
- Docker PS formatting
- Docker Stats formatting
- Docker Volume Inspect formatting
- Docker Version formatting
Docker provides a set of basic functions to manipulate template elements. This is the complete list of the available functions with examples:
join
concatenates a list of strings to create a single string.
It puts a separator between each element in the list.
{% raw %}
$ docker inspect --format '{{join .Args " , "}}' container
{% endraw %}
json
encodes an element as a json string.
{% raw %}
$ docker inspect --format '{{json .Mounts}}' container
{% endraw %}
lower
transforms a string into its lowercase representation.
{% raw %}
$ docker inspect --format "{{lower .Name}}" container
{% endraw %}
split
slices a string into a list of strings separated by a separator.
{% raw %}
$ docker inspect --format '{{split (join .Names "/") "/"}}' container
{% endraw %}
title
capitalizes the first character of a string.
{% raw %}
$ docker inspect --format "{{title .Name}}" container
{% endraw %}
upper
transforms a string into its uppercase representation.
{% raw %}
$ docker inspect --format "{{upper .Name}}" container
{% endraw %}