{"record":{"id":"c0732f827e3958e7","repo":"hashicorp/vagrant","slug":"the-docker-post-install-provisioner-cannot-also-ta","errorCode":null,"errorMessage":"The Docker post-install provisioner cannot also take a Docker post-install\nprovisioner","messagePattern":"The Docker post-install provisioner cannot also take a Docker post-install\nprovisioner","errorType":"exception","errorClass":"VagrantPlugins::DockerProvisioner::DockerError","httpStatus":null,"severity":"error","filePath":"plugins/provisioners/docker/config.rb","lineNumber":11,"sourceCode":"# Copyright IBM Corp. 2010, 2025\n# SPDX-License-Identifier: BUSL-1.1\n\nrequire_relative \"../container/config\"\n\nmodule VagrantPlugins\n  module DockerProvisioner\n    class Config < VagrantPlugins::ContainerProvisioner::Config\n      def post_install_provision(name, **options, &block)\n        # Abort\n        raise DockerError, :wrong_provisioner if options[:type] == \"docker\"\n\n        proxy = VagrantPlugins::Kernel_V2::VMConfig.new\n        proxy.provision(name, **options, &block)\n        @post_install_provisioner = proxy.provisioners.first\n      end\n    end\n  end\nend\n","sourceCodeStart":1,"sourceCodeEnd":20,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/provisioners/docker/config.rb#L1-L20","documentation":"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.","triggerScenarios":"Calling `docker.post_install_provision \"name\", type: \"docker\"` (or a block form that resolves to type docker) in the Vagrantfile's docker provisioner block.","commonSituations":"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.","solutions":["Use a different provisioner type for post-install work: `d.post_install_provision \"shell\", inline: \"docker build ...\"`","Keep docker-specific settings (images, builds, containers) directly on the docker provisioner block, not inside post_install_provision","If you need a second docker step, just add another `config.vm.provision \"docker\"` block with its own settings"],"exampleFix":"# Vagrantfile - before\nconfig.vm.provision \"docker\" do |d|\n  d.post_install_provision \"more-docker\", type: \"docker\" do |dd|\n    dd.images = [\"nginx\"]\n  end\nend\n\n# Vagrantfile - after\nconfig.vm.provision \"docker\" do |d|\n  d.images = [\"nginx\"]\n  d.post_install_provision \"prep\", type: \"shell\", inline: \"echo docker ready\"\nend","handlingStrategy":"validation","validationCode":"# Guard at Vagrantfile authoring time\ntype = \"shell\"\nraise \"docker post_install_provision cannot be type docker\" if type == \"docker\"\nd.post_install_provision \"setup\", type: type, inline: \"echo ok\"","typeGuard":"def valid_post_install_type?(type)\n  !type.nil? && type != \"docker\"\nend","tryCatchPattern":null,"preventionTips":["Reserve post_install_provision for a shell/file step and keep docker settings on the main block","Code-review Vagrantfiles for nested provisioner types; this error is always a config mistake, never environmental"],"tags":["docker","provisioning","vagrant","configuration"],"backgroundTag":"invalid-provisioner-type","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}