I just started with Packer, and want to build AMI and Docker images.
Problem is - that Docker's Ubuntu image have no sudo
, thus - build failed with an error:
docker: /tmp/script_2085.sh: 3: /tmp/script_2085.sh: sudo: not found
Is there any way to add some "conditions" for a shell
provisioner to run cmds with or without sudo
, depending on builder
?
Currently - my template have:
...
"provisioners": [{
"type": "shell",
"inline": [
"sleep 30",
"sudo apt-get update",
"sudo apt-get install -y nginx"
]
}]
...
Add something like:
if which sudo; then sudo apt-get update && sudo apt-get install -y nginx; else apt-get update && apt-get install -y nginx; fi
Looks too weird solution... I'm sure - Packer has facility to do it in a better way.