Issue with the Inline Shell Commands on Packer
I Have Been Trying to Use the Following Command in Packer { "Inline": [ "Sudo Docker Images", "Sudo Docker Image List --Format \"{{. Tag}}\"", ], "Type"...
I have been trying to use the following command in packer
{
"inline" : [
"sudo docker images",
"sudo docker image list --format \"{{.Tag}}\"",
],
"type" : "shell"
}
The docker images command works as expected, prints out the repo, version, etc..., but the second command prints out <no value>, using the same command inside a terminal seems to be fine. Not quite sure why this is happening, any help is much appreciated!
1 Answer
Docker and Packer use the same templating engine which is probably causing Packer to try and interpolate the variable Tag, which presumably you dont have defined/set.
You can try double escaping the braces, but based on this GH comment, that may or may not work.
{
"inline" : [
"sudo docker images",
"sudo docker image list --format \"\\{\\{.Tag\\}\\}\"",
],
"type" : "shell"
}
However, it may be easier just to switch from inline to script