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

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.

Alexander Ross

Alexander Ross

Gaming, Esports & Interactive Media Writer

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.

Share this article
Twitter Facebook Pinterest