{"record":{"id":"f1b53e250c009742","repo":"hashicorp/nomad","slug":"trying-to-map-ports-but-no-network-interface-is-av","errorCode":null,"errorMessage":"Trying to map ports but no network interface is available","messagePattern":"Trying to map ports but no network interface is available","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/docker/driver.go","lineNumber":1452,"sourceCode":"\t\t\t}\n\t\t}\n\tcase len(task.Resources.NomadResources.Networks) > 0:\n\t\tnetwork := task.Resources.NomadResources.Networks[0]\n\n\t\tfor _, port := range network.ReservedPorts {\n\t\t\tports.addMapped(port.Label, network.IP, port.Value, driverConfig.PortMap)\n\t\t}\n\n\t\tfor _, port := range network.DynamicPorts {\n\t\t\tports.addMapped(port.Label, network.IP, port.Value, driverConfig.PortMap)\n\t\t}\n\n\tdefault:\n\t\tif len(driverConfig.PortMap) > 0 {\n\t\t\tif task.Resources.Ports != nil {\n\t\t\t\treturn c, fmt.Errorf(\"'port_map' cannot map group network ports, use 'ports' instead\")\n\t\t\t}\n\t\t\treturn c, fmt.Errorf(\"Trying to map ports but no network interface is available\")\n\t\t}\n\t}\n\thostConfig.PortBindings = make(networkapi.PortMap, len(ports.publishedPorts))\n\tfor port, bindings := range ports.publishedPorts {\n\t\tparsedPort := networkapi.MustParsePort(string(port))\n\t\tconvertedBindings := make([]networkapi.PortBinding, len(bindings))\n\t\tfor i, binding := range bindings {\n\t\t\tconvertedBinding := networkapi.PortBinding{\n\t\t\t\tHostPort: binding.HostPort,\n\t\t\t}\n\t\t\tif binding.HostIP != \"\" {\n\t\t\t\tconvertedBinding.HostIP = netip.MustParseAddr(binding.HostIP)\n\t\t\t}\n\t\t\tconvertedBindings[i] = convertedBinding\n\t\t}\n\t\thostConfig.PortBindings[parsedPort] = convertedBindings\n\t}\n","sourceCodeStart":1434,"sourceCodeEnd":1470,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/docker/driver.go#L1434-L1470","documentation":"The driver only knows how to publish ports when a port source exists: driverConfig.Ports entries, a group network (Ports), or a legacy task network. If none of these are present but port_map is still set, there is no network interface/ports data to map from, so the driver fails with this message.","triggerScenarios":"StartTask -> createContainerConfig hits the default case with len(driverConfig.PortMap) > 0, task.Resources.Ports == nil, and no task.Resources.NomadResources.Networks — port_map without any network block.","commonSituations":"Jobs with no network stanza that still carry leftover port_map config; stripped-down job specs where the network block was removed but the docker driver config was not cleaned up.","solutions":["Add a group network block with named ports and use ports = [...] instead of port_map","Remove the port_map stanza if the container does not need published ports","Define a static/dynamic port in the network block matching the container port"],"exampleFix":"// before\ngroup \"app\" {\n  task \"web\" {\n    driver \"docker\" { port_map { http = 8080 } }\n  }\n}\n// after\ngroup \"app\" {\n  network { port \"http\" {} }\n  task \"web\" {\n    driver \"docker\" { ports = [\"http\"] }\n  }\n}","handlingStrategy":"validation","validationCode":"if len(cfg.PortMap) > 0 && len(group.Network.Ports) == 0 {\n  return errors.New(\"port_map set but no group network ports declared\")\n}","typeGuard":null,"tryCatchPattern":"err := client.StartTask(task); if err != nil && strings.Contains(err.Error(), \"no network interface is available\") { requireNetworkBlock(job) }","preventionTips":["Always pair port publishing with a group network block","Remove stale port_map from jobs without networking","Validate jobs in CI before submission"],"tags":["docker","nomad-driver","ports","network"],"backgroundTag":"incompatible-port-config","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}