{"record":{"id":"ac6096bc55f0d417","repo":"hashicorp/vagrant","slug":"the-docker-provider-is-unable-to-connect-the-conta","errorCode":null,"errorMessage":"The Docker provider is unable to connect the container to the\ndefined network due to a missing network name. Please validate\nyour configuration and try again.\n\n  Container: %{container}\n  Network Number: %{index}","messagePattern":"The Docker provider is unable to connect the container to the\ndefined network due to a missing network name\\. Please validate\nyour configuration and try again\\.\n\n  Container: %(.+?)\n  Network Number: %(.+?)","errorType":"exception","errorClass":"VagrantPlugins::DockerProvider::Errors::NetworkNameMissing","httpStatus":null,"severity":"error","filePath":"plugins/providers/docker/action/connect_networks.rb","lineNumber":57,"sourceCode":"          if machine.provider.host_vm?\n            @logger.debug(\"Not setting up networks because docker host_vm is in use\")\n            return @app.call(env)\n          end\n\n          env[:ui].info(I18n.t(\"docker_provider.network_connect\"))\n\n          connections = env[:docker_connects] || {}\n\n          machine.config.vm.networks.each_with_index do |args, idx|\n            type, options = args\n            next if type != :private_network && type != :public_network\n\n            network_options = scoped_hash_override(options, :docker_connect)\n            network_options.delete_if{|k,_| options.key?(k)}\n            network_name = connections[idx]\n\n            if !network_name\n              raise Errors::NetworkNameMissing,\n                index: idx,\n                container: machine.name\n            end\n\n            @logger.debug(\"Connecting network #{network_name} to container guest #{machine.name}\")\n            if options[:ip] && options[:type] != \"dhcp\"\n              if IPAddr.new(options[:ip]).ipv4?\n                network_options[:ip] = options[:ip]\n              else\n                network_options[:ip6] = options[:ip]\n              end\n            end\n            network_options[:alias] = options[:alias] if options[:alias]\n            connect_opts = generate_connect_cli_arguments(network_options)\n            machine.provider.driver.connect_network(network_name, machine.id, connect_opts)\n          end\n\n          @app.call(env)","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/hashicorp/vagrant/blob/35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5/plugins/providers/docker/action/connect_networks.rb#L39-L75","documentation":"During `vagrant up`, the Docker provider runs PrepareNetworks, which computes/creates docker networks and stores their names in env[:docker_connects] keyed by network index; ConnectNetworks later reads connections[idx] to run `docker network connect`. If the entry for a private/public network index is missing, NetworkNameMissing is raised with the container name and index.","triggerScenarios":"ConnectNetworks executing in an action env that PrepareNetworks never populated: custom middleware chains or plugins invoking the docker provider's connect action directly, an interrupted earlier prepare step, or any state where env[:docker_connects] is absent or lacks that index.","commonSituations":"Third-party tooling that reuses Docker provider actions outside the built-in up chain; a partially failed `vagrant up` followed by a partial re-run; version drift between the prepare and connect actions.","solutions":["Clean re-run so the full chain executes: `vagrant destroy -f && vagrant up`","Update Vagrant - fixes to the prepare/connect handoff ship in patch releases","If you build custom middleware, invoke the provider's built-in up chain instead of ConnectNetworks in isolation","Reproduce with VAGRANT_LOG=debug and look for 'Connecting network' entries to identify which index is missing"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"# before invoking the docker provider's ConnectNetworks action\nmissing = machine.config.vm.networks.each_with_index.select do |(type, _), idx|\n  [:private_network, :public_network].include?(type) && env[:docker_connects].to_h[idx].nil?\nend\nraise 'PrepareNetworks must populate env[:docker_connects] first' unless missing.empty?","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Prefer the provider's built-in up chain over hand-assembled middleware","Use destroy+up rather than resuming partially failed runs when custom networking is involved","Pin a known-good Vagrant version across the team so prepare and connect stay in sync"],"tags":["vagrant","docker","network","provider","middleware"],"backgroundTag":"docker-network-not-found","analyzedSha":"35f3160f4ad6edc3a9f3aa9570adfc1a4d73aaa5","analyzedAt":"2026-08-21T13:34:32.514Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}