Closed hc-github-team-packer closed 1 year ago
Hello there, @CollinLeishman, did you try doing this with HCL2 ? Did you have the same issue ?
Got the same issue (my config is JSON too). Interestingly, Packer v1.4.5 works fine while v1.7.6 does not
one of the possible solutions is to change the code like this, I think.
for host, guest := range config.Volumes {
if strings.HasPrefix(host, "~/") {
homedir, _ := os.UserHomeDir()
host = filepath.Join(homedir, host[2:])
}
args = append(args, "-v", fmt.Sprintf("%s:%s", host, guest))
}
I am going to test if this change works.
This issue was originally opened by @CollinLeishman in https://github.com/hashicorp/packer/issues/11163 and has been migrated to this repository. The original issue description is below.
Overview of the Issue
Trying to mount current working directory(ex:/home/user/testing/ on my machine to /home/user/testing/ on docker container) fails because the volume variable is not rendered for the container. It tries you mount
/home/user/testing/
to{{ user
workspace}}/build/repo
on the docker container.Reproduction Steps
Reproduced with Docker version 20.10.7, build f0df350 and 17.12.1-ce, build 7390fc6, so install either of those.
PACKER_LOG=1 packer build -var 'workspace=/home/user/testing/' testing.json
Packer version
1.7.3
Simplified Packer Buildfile
Operating system and Environment details
Linux removed_hostname 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux
Log Fragments and crash.log files