hashicorp/vagrant · error · VagrantPlugins::DockerProvisioner::DockerError

The Docker post-install provisioner cannot also take a Docke

Error message

The Docker post-install provisioner cannot also take a Docker post-install
provisioner

What it means

Raised by DockerProvisioner::Config#post_install_provision when the provisioner passed via `options[:type]` is itself "docker". The post-install hook exists to run auxiliary setup (e.g. a shell script) right after Docker is installed; nesting a docker provisioner there would recursively trigger Docker installation/start logic, so Vagrant aborts the config call immediately. This is a hard configuration validation, not a runtime guest failure.

Source

Thrown at plugins/provisioners/docker/config.rb:11

# Copyright IBM Corp. 2010, 2025
# SPDX-License-Identifier: BUSL-1.1

require_relative "../container/config"

module VagrantPlugins
  module DockerProvisioner
    class Config < VagrantPlugins::ContainerProvisioner::Config
      def post_install_provision(name, **options, &block)
        # Abort
        raise DockerError, :wrong_provisioner if options[:type] == "docker"

        proxy = VagrantPlugins::Kernel_V2::VMConfig.new
        proxy.provision(name, **options, &block)
        @post_install_provisioner = proxy.provisioners.first
      end
    end
  end
end

View on GitHub (pinned to 35f3160f4a)

Solutions

  1. Use a different provisioner type for post-install work: `d.post_install_provision "shell", inline: "docker build ..."`
  2. Keep docker-specific settings (images, builds, containers) directly on the docker provisioner block, not inside post_install_provision
  3. If you need a second docker step, just add another `config.vm.provision "docker"` block with its own settings

Example fix

# Vagrantfile - before
config.vm.provision "docker" do |d|
  d.post_install_provision "more-docker", type: "docker" do |dd|
    dd.images = ["nginx"]
  end
end

# Vagrantfile - after
config.vm.provision "docker" do |d|
  d.images = ["nginx"]
  d.post_install_provision "prep", type: "shell", inline: "echo docker ready"
end
Defensive patterns

Strategy: validation

Validate before calling

# Guard at Vagrantfile authoring time
type = "shell"
raise "docker post_install_provision cannot be type docker" if type == "docker"
d.post_install_provision "setup", type: type, inline: "echo ok"

Type guard

def valid_post_install_type?(type)
  !type.nil? && type != "docker"
end

Prevention

When it happens

Trigger: Calling `docker.post_install_provision "name", type: "docker"` (or a block form that resolves to type docker) in the Vagrantfile's docker provisioner block.

Common situations: Copy-pasting a generic `config.vm.provision "docker"` block into post_install_provision; misunderstanding that post_install_provision is for one auxiliary provisioner (shell/file/podman etc.), not for more docker configuration.

Related errors


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