hashicorp / hashicorp/packer-plugin-docker

Workaround for #8120: "Unable to use packer with distroless base images"

Open
#86 0 comments 0 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 @mprzybylski in https://github.com/hashicorp/packer/issues/11283 and has been migrated to this repository. The original issue description is below._

---
Hello,

I took @SwampDragons up on her suggestion in issue #8120 to "tinker and can figure out how to make (distroless images) work":
- Start from one of the distroless ["debug" images](https://github.com/GoogleContainerTools/distroless#debug-images). These are identical to the base images except that they have busybox installed.
- Change the `run_command` for the docker source to `["-d", "-i", "-t", "--entrypoint=/busybox/sh", "--", "{{.Image}}"]`
- Create a symlink from `/busybox/sh` to `/bin/sh` to make shell provisioners work:
```
provisioner "shell-local"{
inline = ["docker exec ${build.ID} ln -s /busybox/sh /bin/sh"]
}
```
- Optional: run a shell-local, docker-exec-hack provisioner to delete the `/busybox` directory after all other provisioning is complete:
```
provisioner "shell-local" {
only = ["docker.ebpf_sensor"]
inline = ["docker exec ${build.ID} rm -rf /bin/sh /busybox"]
}
```

Hope this helps!

-Mike Przybylski

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.