hashicorp / packer-plugin-docker

Packer plugin for Docker Builder
https://www.packer.io/docs/builders/docker
Mozilla Public License 2.0
31 stars 25 forks source link

No meaningful error even in debug mode when Docker Desktop (WSL2) is not running #115

Open dasavick opened 1 year ago

dasavick commented 1 year ago

Overview of the Issue

I'm running Docker Desktop on Windows and execution of docker command in the WSL2 results in an error until Docker Desktop is started (assuming auto start is disabled):

The command 'docker' could not be found in this WSL 2 distro.
We recommend to activate the WSL integration in Docker Desktop settings.

For details about using Docker Desktop with WSL 2, visit:

https://docs.docker.com/go/wsl2/

Until Docker Desktop is started, packer fails in a bit unexpected way:

$ packer build -debug .
Debug mode enabled. Builds will not be parallelized.
docker.openjdk: output will be in this color.

Build 'docker.openjdk' errored after 62 milliseconds 741 microseconds: exit status 1

==> Wait completed after 62 milliseconds 798 microseconds

==> Some builds didn't complete successfully and had errors:
--> docker.openjdk: exit status 1

==> Builds finished but no artifacts were created.

Reproduction Steps

Plugin and Packer version

Packer v1.8.3

Simplified Packer Buildfile

packer {
  required_plugins {
    docker = {
      version = ">= 1.0.1"
      source  = "github.com/hashicorp/docker"
    }
  }
}

source "docker" "openjdk" {
  image  = "eclipse-temurin:18-jre-jammy"
  commit = true
}

build {
  sources = [
    "source.docker.openjdk"
  ]
  provisioner "shell" {
    inline = ["mkdir /app"]
  }
  post-processor "docker-tag" {
    repository = "test/test1"
    tags       = ["{{isotime `2006-01-02`}}"]
  }
}

Operating system and Environment details

Windows 11, WSL2, Docker Desktop

nywilken commented 1 year ago

Hi @PinkLolicorn thanks for reaching out. I can see the expectation for debug information when running a Packer build with the debug flag. I think this warrants some changes to our docs. The debug flag -debug does not change the log verbosity but instead allows the user to interactively step through a build.

You can enable debug logging by setting the PACKER_LOG environment variable PACKER_LOG=1 packer build .. The environment variable when set will inform Packer to output all log information to STDOOUT. The amount of information outputted varies per builder but I think it should help provide some insight into why the build is failing so quickly.

Please try your build again with the PACKER_LOG=1 and let us know if you're still running into issue. Cheers!

dasavick commented 1 year ago

The amount of information outputted varies per builder but I think it should help provide some insight into why the build is failing so quickly.

Unfortunately, there is still no specific information there. I don't see anything more than exit status 1.

2022/09/04 17:09:10 [INFO] Packer version: 1.8.3 [go1.17.11 linux amd64]
2022/09/04 17:09:10 [TRACE] discovering plugins in /usr/bin
2022/09/04 17:09:10 [TRACE] discovering plugins in /home/user/.config/packer/plugins
2022/09/04 17:09:10 [DEBUG] Discovered plugin: docker = /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64
2022/09/04 17:09:10 [INFO] found external [-packer-default-plugin-name-] builders from docker plugin
2022/09/04 17:09:10 [INFO] found external [import push save tag] post-processors from docker plugin
2022/09/04 17:09:10 [TRACE] discovering plugins in .
2022/09/04 17:09:11 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/09/04 17:09:11 [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/09/04 17:09:11 [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/09/04 17:09:11 [INFO] Setting cache directory: /home/user/.cache/packer
2022/09/04 17:09:11 [TRACE] listing potential installations for "github.com/hashicorp/docker" that match ">= 1.0.1". plugingetter.ListInstallationsOptions{FromFolders:[]string{"/usr/bin/packer", ".", "/home/user/.config/packer/plugins"}, BinaryInst
allationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc00018c580)}}}}
2022/09/04 17:09:11 [TRACE] Found the following "github.com/hashicorp/docker" installations: [{/home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64 v1.0.8}]
2022/09/04 17:09:11 [INFO] found external [-packer-default-plugin-name-] builders from docker plugin
2022/09/04 17:09:11 [INFO] found external [import push save tag] post-processors from docker plugin
2022/09/04 17:09:11 [TRACE] Starting external plugin /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64 start builder -packer-default-plugin-name-
2022/09/04 17:09:11 Starting plugin: /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64 []string{"/home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64", "start", "builder", "-packer-default-plugin-name-"}
2022/09/04 17:09:11 Waiting for RPC address for: /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64
2022/09/04 17:09:11 packer-plugin-docker_v1.0.8_x5.0_linux_amd64 plugin: 2022/09/04 17:09:11 Plugin address: unix /tmp/packer-plugin1937736406
2022/09/04 17:09:11 packer-plugin-docker_v1.0.8_x5.0_linux_amd64 plugin: 2022/09/04 17:09:11 Waiting for connection...
2022/09/04 17:09:11 Received unix RPC address for /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64: addr is /tmp/packer-plugin1937736406
2022/09/04 17:09:11 packer-plugin-docker_v1.0.8_x5.0_linux_amd64 plugin: 2022/09/04 17:09:11 Serving a plugin connection...
2022/09/04 17:09:11 packer-plugin-docker_v1.0.8_x5.0_linux_amd64 plugin: 2022/09/04 17:09:11 [TRACE] starting builder -packer-default-plugin-name-
2022/09/04 17:09:11 [TRACE] Starting internal plugin packer-provisioner-shell
2022/09/04 17:09:11 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-provisioner-shell"}
2022/09/04 17:09:11 Waiting for RPC address for: /usr/bin/packer
2022/09/04 17:09:11 packer-provisioner-shell plugin: [INFO] Packer version: 1.8.3 [go1.17.11 linux amd64]
2022/09/04 17:09:11 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/09/04 17:09:11 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-shell plugin: [INFO] Setting cache directory: /home/user/.cache/packer
2022/09/04 17:09:11 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2022/09/04 17:09:11 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin3674172991
2022/09/04 17:09:11 packer-provisioner-shell plugin: Waiting for connection...
2022/09/04 17:09:11 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin3674172991
2022/09/04 17:09:11 packer-provisioner-shell plugin: Serving a plugin connection...
2022/09/04 17:09:11 [TRACE] Starting internal plugin packer-provisioner-shell
2022/09/04 17:09:11 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-provisioner-shell"}
2022/09/04 17:09:11 Waiting for RPC address for: /usr/bin/packer
2022/09/04 17:09:11 packer-provisioner-shell plugin: [INFO] Packer version: 1.8.3 [go1.17.11 linux amd64]
2022/09/04 17:09:11 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/09/04 17:09:11 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-shell plugin: [INFO] Setting cache directory: /home/user/.cache/packer
2022/09/04 17:09:11 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2022/09/04 17:09:11 packer-provisioner-shell plugin: Plugin address: unix /tmp/packer-plugin2368433007
2022/09/04 17:09:11 packer-provisioner-shell plugin: Waiting for connection...
2022/09/04 17:09:11 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin2368433007
2022/09/04 17:09:11 packer-provisioner-shell plugin: Serving a plugin connection...
2022/09/04 17:09:11 [TRACE] Starting internal plugin packer-provisioner-file
2022/09/04 17:09:11 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-provisioner-file"}
2022/09/04 17:09:11 Waiting for RPC address for: /usr/bin/packer
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] Packer version: 1.8.3 [go1.17.11 linux amd64]
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-file plugin: [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] Setting cache directory: /home/user/.cache/packer
2022/09/04 17:09:11 packer-provisioner-file plugin: args: []string{"packer-provisioner-file"}
2022/09/04 17:09:11 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin696867535
2022/09/04 17:09:11 packer-provisioner-file plugin: Plugin address: unix /tmp/packer-plugin696867535
2022/09/04 17:09:11 packer-provisioner-file plugin: Waiting for connection...
2022/09/04 17:09:11 packer-provisioner-file plugin: Serving a plugin connection...
2022/09/04 17:09:11 [TRACE] Starting internal plugin packer-provisioner-file
2022/09/04 17:09:11 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-provisioner-file"}
2022/09/04 17:09:11 Waiting for RPC address for: /usr/bin/packer
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] Packer version: 1.8.3 [go1.17.11 linux amd64]
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-file plugin: [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] Setting cache directory: /home/user/.cache/packer
2022/09/04 17:09:11 packer-provisioner-file plugin: args: []string{"packer-provisioner-file"}
2022/09/04 17:09:11 packer-provisioner-file plugin: Plugin address: unix /tmp/packer-plugin4240067689
2022/09/04 17:09:11 packer-provisioner-file plugin: Waiting for connection...
2022/09/04 17:09:11 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin4240067689
2022/09/04 17:09:11 packer-provisioner-file plugin: Serving a plugin connection...
2022/09/04 17:09:11 [TRACE] Starting internal plugin packer-provisioner-file
2022/09/04 17:09:11 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-provisioner-file"}
2022/09/04 17:09:11 Waiting for RPC address for: /usr/bin/packer
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] Packer version: 1.8.3 [go1.17.11 linux amd64]
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-file plugin: [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] Setting cache directory: /home/user/.cache/packer
2022/09/04 17:09:11 packer-provisioner-file plugin: args: []string{"packer-provisioner-file"}
2022/09/04 17:09:11 packer-provisioner-file plugin: Plugin address: unix /tmp/packer-plugin259199936
2022/09/04 17:09:11 packer-provisioner-file plugin: Waiting for connection...
2022/09/04 17:09:11 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin259199936
2022/09/04 17:09:11 packer-provisioner-file plugin: Serving a plugin connection...
2022/09/04 17:09:11 [TRACE] Starting internal plugin packer-provisioner-file
2022/09/04 17:09:11 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-provisioner-file"}
2022/09/04 17:09:11 Waiting for RPC address for: /usr/bin/packer
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] Packer version: 1.8.3 [go1.17.11 linux amd64]
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-file plugin: [WARN] Config file doesn't exist: /home/user/.packerconfig
2022/09/04 17:09:11 packer-provisioner-file plugin: [INFO] Setting cache directory: /home/user/.cache/packer
2022/09/04 17:09:11 packer-provisioner-file plugin: args: []string{"packer-provisioner-file"}
2022/09/04 17:09:11 packer-provisioner-file plugin: Plugin address: unix /tmp/packer-plugin618043710
2022/09/04 17:09:11 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin618043710
2022/09/04 17:09:11 packer-provisioner-file plugin: Waiting for connection...
2022/09/04 17:09:11 packer-provisioner-file plugin: Serving a plugin connection...
2022/09/04 17:09:11 [TRACE] Starting external plugin /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64 start post-processor tag
2022/09/04 17:09:11 Starting plugin: /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64 []string{"/home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64", "start", "post-processor", "tag"}
2022/09/04 17:09:11 Waiting for RPC address for: /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64
2022/09/04 17:09:11 packer-plugin-docker_v1.0.8_x5.0_linux_amd64 plugin: 2022/09/04 17:09:11 Plugin address: unix /tmp/packer-plugin3195034368
2022/09/04 17:09:11 packer-plugin-docker_v1.0.8_x5.0_linux_amd64 plugin: 2022/09/04 17:09:11 Waiting for connection...
2022/09/04 17:09:11 Received unix RPC address for /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64: addr is /tmp/packer-plugin3195034368
2022/09/04 17:09:11 packer-plugin-docker_v1.0.8_x5.0_linux_amd64 plugin: 2022/09/04 17:09:11 Serving a plugin connection...
2022/09/04 17:09:11 packer-plugin-docker_v1.0.8_x5.0_linux_amd64 plugin: 2022/09/04 17:09:11 [TRACE] starting post-processor tag
2022/09/04 17:09:11 Build debug mode: false
docker.runtime: output will be in this color.
2022/09/04 17:09:11 Force build: false

2022/09/04 17:09:11 On error:
2022/09/04 17:09:11 Waiting on builds to complete...
2022/09/04 17:09:11 Starting build run: docker.runtime
2022/09/04 17:09:11 Running builder:
2022/09/04 17:09:11 [INFO] (telemetry) Starting builder docker.runtime
2022/09/04 17:09:11 [INFO] (telemetry) ending docker.runtime
Build 'docker.runtime' errored after 61 milliseconds 858 microseconds: exit status 1
==> Wait completed after 61 milliseconds 935 microseconds
2022/09/04 17:09:11 machine readable: docker.runtime,error []string{"exit status 1"}
==> Some builds didn't complete successfully and had errors:
==> Builds finished but no artifacts were created.
--> docker.runtime: exit status 1
2022/09/04 17:09:11 [INFO] (telemetry) Finalizing.

==> Builds finished but no artifacts were created.
2022/09/04 17:09:11 waiting for all plugin processes to complete...
2022/09/04 17:09:11 /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64: plugin process exited
2022/09/04 17:09:11 /home/user/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64: plugin process exited
2022/09/04 17:09:11 /usr/bin/packer: plugin process exited
2022/09/04 17:09:11 /usr/bin/packer: plugin process exited
2022/09/04 17:09:11 /usr/bin/packer: plugin process exited
2022/09/04 17:09:11 /usr/bin/packer: plugin process exited
2022/09/04 17:09:11 /usr/bin/packer: plugin process exited
2022/09/04 17:09:11 /usr/bin/packer: plugin process exited