hashicorp/vagrant · error · VagrantPlugins::DockerProvider::Errors::BuildError

Vagrant received unknown output from `docker build` while bu

Error message

Vagrant received unknown output from `docker build` while building a container: %{result}

What it means

After running `docker build`, the Docker driver parses stdout to extract the image ID: a trailing 'Successfully built <id>' line, or - when podman emulates the docker CLI - the last 64-hex-char token. When the output matches neither pattern, BuildError is raised with the raw result; the code comment notes that reaching this guard at all indicates output Vagrant does not expect.

Source

Thrown at plugins/providers/docker/driver.rb:52

        if !matches
          # Check for output of docker using containerd backend store
          matches = result.scan(/exporting manifest list .+:([^\s]+)/i).last
        end
        if !matches
          if podman?
            # Check for podman format when it is emulating docker CLI.
            # Podman outputs the full hash of the container on
            # the last line after a successful build.
            match = result.split.select { |str| str.match?(/^[0-9a-z]{64}/) }.last
            return match[0..7] unless match.nil?
          else
            matches = result.scan(/Successfully built (.+)$/i).last
          end

          if !matches
            # This will cause a stack trace in Vagrant, but it is a bug
            # if this happens anyways.
            raise Errors::BuildError, result: result
          end
        end

        # Return the matched group `id`
        matches[0].strip
      end

      # Check if podman emulating docker CLI is enabled.
      #
      # @return [Bool]
      def podman?
        execute('docker', '--version').include?("podman")
      end

      def create(params, **opts, &block)
        image   = params.fetch(:image)
        links   = params.fetch(:links)
        ports   = Array(params[:ports])

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Read the result text in the error - the actual build failure (failing Dockerfile step, missing context) is printed there
  2. Disable BuildKit for Vagrant builds: DOCKER_BUILDKIT=0 vagrant up (export it in your shell or CI)
  3. Update Vagrant - newer releases teach the parser BuildKit and podman output formats
  4. Iterate outside Vagrant: re-run the docker build command shown in the error directly until the Dockerfile is good

Example fix

# before
export DOCKER_BUILDKIT=1
vagrant up   # BuildError: unparseable build output

# after
export DOCKER_BUILDKIT=0
vagrant up
Defensive patterns

Strategy: try-catch

Validate before calling

# smoke-test the build path before letting Vagrant parse its output
DOCKER_BUILDKIT=0 docker build -q -t probe . >/dev/null && vagrant up

Try / catch

begin
  image_id = driver.build(build_dir)
rescue VagrantPlugins::DockerProvider::Errors::BuildError => e
  # the raw output is in e.extra_data[:result]; show it, do not retry the same parse
  abort "docker build output not understood: #{e.extra_data[:result]}"
end

Prevention

When it happens

Trigger: Build output that omits 'Successfully built' - BuildKit-style output (DOCKER_BUILDKIT=1, 'writing image sha256:...'), newer docker CLI formats, podman emulation edge cases, or a build whose failure text never matched the success regex.

Common situations: BuildKit enabled by default on modern Docker; podman/docker aliases; build failures whose real error text only appears inside the %{result} payload.

Related errors


AI-assisted analysis of hashicorp/vagrant@35f3160f4a (2026-08-21). Data as JSON: /api/errors/9e5258114579ee08. Report an issue: GitHub.