Skip to content

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

@hc-github-team-packer

Description

@hc-github-team-packer

This issue was originally opened by @mprzybylski in hashicorp/packer#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. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions