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" : "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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like