$ docker run -itd --name test centos:6
$ docker exec -it test /bin/bash
[root@006a9c3195b6 /]# echo 'echo SUCCESS' > /root/test.sh
[root@006a9c3195b6 /]# chmod +x /root/test.sh
[root@006a9c3195b6 /]# echo 'export PATH=/root:$PATH' > /etc/profile.d/my_settings.sh
[root@006a9c3195b6 /]# echo 'PATH=/root:$PATH' > /etc/environment
[root@006a9c3195b6 /]# echo 'export PATH=/root:$PATH' > ~/.bashrc
[root@006a9c3195b6 /]# exit
$ docker commit test test-image:1
$ docker exec -it test-image:1 test.sh
OCI runtime exec failed: exec failed: container_linux.go:296: starting container process caused "exec: \"test.sh\": executable file not found in $PATH": unknown
$ docker run -it test-image:1 /bin/bash
[root@8f821c7b9b82 /]# test.sh
SUCCESS
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/e4cb8df6-fe4e-48bc-9064-64ce4cabae79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/CAHqq0eyK01mTYLZDQmxdz-U%3DWbFj39dFkcNHEDZ883nXukym9Q%40mail.gmail.com.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/e4cb8df6-fe4e-48bc-9064-64ce4cabae79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Alvaro
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
"changes": ["ENV PATH=...:${PATH}"]
"builders": [{
"type": "docker",
"image": "{{user `docker_source_repo`}}:{{user `docker_source_tag`}}",
"export_path": "{{user `build_dir`}}/docker-{{user `docker_target_repo`}}/{{user `docker_target_tag`}}.tar",
"run_command": [
"-d",
"-i",
"-t",
"--name",
"{{user `container_name`}}",
"--privileged",
"{{.Image}}",
"/bin/bash"
],
"changes": [
"ENV PATH=/usr/local/texlive/2018/bin/x86_64-linux/:${PATH}"
]
}],
docker container inspect <ID>
...
"Config": {
"Hostname": "82e7c913d455",
"Domainname": "",
"User": "",
"AttachStdin": true,
"AttachStdout": true,
"AttachStderr": true,
"Tty": true,
"OpenStdin": true,
"StdinOnce": true,
"Env": null,
"Cmd": [
"<my_binary_here>",
"-p",
".",
"-o",
"/tmp"
],
"Image": "<my_image_here>",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
...
docker run -it <my_image_here> <my_binary_here>
However, I would like to use this opportunity to ask if after all there is an alternative to "--changes" that can be performed by one of provisioners. Reason I'm looking for an alternative is that I'm using Ansible playbook to provision both Docker and Vagrant images. My only option for now to set PATH correctly in Docker seems to be to duplicate PATH configuration inside Packer template and I don't like the idea of repeating the configuration for obvious reasons.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/60a0484d-9850-4046-82b0-0b09152b6447%40googlegroups.com.
"builders": [{
"type": "docker",
"image": "{{user `docker_source_repo`}}:{{user `docker_source_tag`}}",
"commit": true,
"run_command": [
"-d",
"-i",
"-t",
"--name",
"{{user `container_name`}}",
"--privileged",
"{{.Image}}",
"/bin/bash"
],
"changes": [
"ENV PATH=/usr/local/texlive/2018/bin/x86_64-linux/:${PATH}"
]
}],
"Env": [
"PATH=/usr/local/texlive/2018/bin/x86_64-linux/:"
],
{
"builders": [{
"type": "docker",
"image": "centos:6",
"commit": true,
"run_command": [
"-d",
"-i",
"-t",
"--privileged",
"{{.Image}}",
"/bin/bash"
],
"changes": [
"ENV PATH=/usr/local/texlive/2018/bin/x86_64-linux/:${PATH}"
]
}]
}
$ packer build docker.json
[...]
==> Builds finished. The artifacts of successful builds are:
--> docker: Imported Docker image: sha256:665e385658c14cf0f19fdd584fcbbd18df0f50e281896cc6cae470ec2eee085a
$ docker inspect sha256:665e385658c14cf0f19fdd584fcbbd18df0f50e281896cc6cae470ec2eee085a -f "{{.Config.Env}}"
[PATH=/usr/local/texlive/2018/bin/x86_64-linux/:]
I was exporting the container instead of committing it by builder.
But as you can see ${PATH} from "changes" is not being resolved (or it is actually empty for some reason).
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/1a1ec019-349e-42ef-bef8-719e588f4349%40googlegroups.com.
Docker Engine: 18.03.0-ce-rc1
Docker for Mac Version 18.03.0-ce-rc1-mac54 (23022)
Which gives: Linux 3a126b636a9a 4.9.75-linuxkit-aufs #1 SMP Tue Jan 9 10:58:17 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/67c3c116-3480-40f7-a018-ace8c10c5e9c%40googlegroups.com.