Skip to content

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

@sandrwich

Description

@sandrwich

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

  • Install WSL2 and Docker Desktop
  • Make sure docker is not started
  • Run packer build with a docker source

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions