Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do the curly braces mean in docker inspect --format "{{.State.Pid}}"?

Tags:

bash

docker

I'm looking through this shell script and I'm curious what the double curly braces are doing in this line:

https://github.com/jpetazzo/nsenter/blob/master/docker-enter#L16

I know that curly braces in shell are used for grouping, but what does two sets of curly braces do? If someone could explain this:

docker inspect --format "{{.State.Pid}}"

I would really appreciate it.

like image 898
User314159 Avatar asked Mar 18 '23 20:03

User314159


1 Answers

The context of this was a command running

docker inspect --format "{{.State.Pid}}"

The Docker option --format takes a go template. Double-curly-braces are meaningful in Go templates, not in bash.

See the Go text.template package documentation for details. To quote from same:

"Actions"--data evaluations or control structures--are delimited by "{{" and "}}"; all text outside actions is copied to the output unchanged.

like image 70
Charles Duffy Avatar answered Apr 24 '23 09:04

Charles Duffy