hashicorp / hashicorp/packer-plugin-docker

/bin/sh: 1: /home/ubuntu/packer/script_2501.sh: Permission denied

Open
#118 0 comments 2 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
40
Forks
29
PR merge metrics
No merged PRs in 30d

Description

_This issue was originally opened by @fredleger in https://github.com/hashicorp/packer/issues/11968 and has been migrated to this repository. The original issue description is below._

---

#### Community Note

* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment

#### Overview of the Issue

As stated in #5307 packer even at latest version upload temporary script files with wrong owner if the container is nut run as root

#### Reproduction Steps

```sh
source "docker" "container" {
commit = true
image = "ubuntu:jammy"
run_command = [
"-d", "-i", "-t", "--user", "1000", "--entrypoint=/bin/sh", "--", "{{.Image}}"
]
}
```

### Packer version

v1.8.3

### Simplified Packer Template

see above

### Operating system and Environment details

macosx ruuning rancher desktop for docker (so at the end linux)

### Log Fragments and crash.log files

```
==> docker.container: Starting docker container...
docker.container: Run command: docker run -v /Users/frederic/.packer.d/tmp2545466742:/packer-files -d -i -t --user 1000 --entrypoint=/bin/sh -- ubuntu:jammy
docker.container: Container ID: eee892b4cf201e56176d93c5cd131b2ed6c76f4e4d342b8eed7c7479833718cc
==> docker.container: Pausing after run of step 'StepRun'. Press enter to continue.
==> docker.container: Using docker communicator to connect: 172.17.0.2
==> docker.container: Pausing after run of step 'StepConnect'. Press enter to continue.
==> docker.container: Pausing before the next provisioner . Press enter to continue.
==> docker.container: Provisioning with shell script: /var/folders/n_/jtqch7ls28534bbt4hl905mr0000gn/T/packer-shell1344318242
==> docker.container: chmod: changing permissions of '/home/ubuntu/packer/script_2501.sh': Operation not permitted
==> docker.container: /bin/sh: 1: /home/ubuntu/packer/script_2501.sh: Permission denied
==> docker.container: Script exited with non-zero exit status: 126. Allowed exit codes are: [0]
==> docker.container: Step "StepProvision" failed
```

In the container:

```sh
buntu@3c5cc3a18ffc:~/packer$ ls -l
total 4
-rw------- 1 501 dialout 66 Sep 1 15:02 script_4966.sh
```

The owner id is 501 (which is my host user id) and not 1000 as it should be

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.