Skip to content

theohbrothers/docker-packer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

docker-packer

github-actions github-release docker-image-size

Dockerized packer with useful tools.

Tags

Tag Dockerfile Build Context
:1.7.7-sops-ubuntu-20.04, :latest View
:1.7.7-sops-qemu-ubuntu-20.04 View
:1.7.7-sops-virtualbox-7.0.8-ubuntu-20.04 View
:1.7.7-sops-virtualbox-6.1.44-ubuntu-20.04 View
:1.7.7-sops-virtualbox-6.1.40-ubuntu-20.04 View
:1.7.7-sops-virtualbox-6.1.26-ubuntu-20.04 View
:1.7.7-sops-qemu-ubuntu-18.04 View
:1.7.7-sops-virtualbox-6.0.24-ubuntu-18.04 View
:1.7.7-sops-virtualbox-5.2.44-ubuntu-16.04 View

Usage

Packer configuration can be done via .packerconfig config file or environment variables (e.g. PACKER_LOG=1 for verbose logging). Environment variables are preferred when using docker.

QEMU builder

# Note: The GID of the group 'kvm' in the container must match the host's. If not, use --privileged instead of --device. See: https://stackoverflow.com/questions/48422001/how-to-launch-qemu-kvm-from-inside-a-docker-container
docker run --rm -it \
    --device /dev/kvm \
    -v $(pwd):/src \
    -w /src \
    theohbrothers/docker-packer:1.7.7-sops-qemu-ubuntu-20.04 packer build template.json

See examples:

Virtualbox builder

The host may need to have an exact matching virtualbox version, or at least the same virtualbox minor version, if not virtualbox may not be able to start VMs. To verify virtualbox can start VMs, run the following, ensuring there is no error message:

docker run --rm -it \
    --device /dev/vboxdrv \
    theohbrothers/docker-packer:1.7.7-sops-virtualbox-7.0.8-ubuntu-20.04 vboxmanage --version

If all is well, to build a VM image:

docker run --rm -it \
    --device /dev/vboxdrv \
    -v $(pwd):/src \
    -w /src \
    theohbrothers/docker-packer:1.7.7-sops-virtualbox-7.0.8-ubuntu-20.04 packer build template.json

See examples:

Other builder(s)

docker run --rm -it \
    -v $(pwd):/src \
    -w /src \
    theohbrothers/docker-packer:1.7.7-sops-ubuntu-20.04 packer build template.json

Development

Requires Windows powershell or pwsh.

# Install Generate-DockerImageVariants module: https://github.com/theohbrothers/Generate-DockerImageVariants
Install-Module -Name Generate-DockerImageVariants -Repository PSGallery -Scope CurrentUser -Force -Verbose

# Edit ./generate templates

# Generate the variants
Generate-DockerImageVariants .