{"record":{"id":"3fb6a15d61f0e692","repo":"hashicorp/nomad","slug":"image-name-required-for-docker-driver","errorCode":null,"errorMessage":"image name required for docker driver","messagePattern":"image name required for docker driver","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/docker/driver.go","lineNumber":342,"sourceCode":"\tif taskCfg.StderrPath == os.DevNull && taskCfg.StdoutPath == os.DevNull {\n\t\treturn false\n\t}\n\treturn true\n}\n\nfunc (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *drivers.DriverNetwork, error) {\n\tif _, ok := d.tasks.Get(cfg.ID); ok {\n\t\treturn nil, nil, fmt.Errorf(\"task with ID %q already started\", cfg.ID)\n\t}\n\n\tvar driverConfig TaskConfig\n\n\tif err := cfg.DecodeDriverConfig(&driverConfig); err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to decode driver config: %v\", err)\n\t}\n\n\tif driverConfig.Image == \"\" {\n\t\treturn nil, nil, fmt.Errorf(\"image name required for docker driver\")\n\t}\n\n\tdriverConfig.Image = strings.TrimPrefix(driverConfig.Image, \"https://\")\n\n\tdriverConfig.ImagePullTimeout = getValue(driverConfig.ImagePullTimeout, d.config.ImagePullTimeout)\n\n\thandle := drivers.NewTaskHandle(taskHandleVersion)\n\thandle.Config = cfg\n\n\t// we'll need the normal docker client\n\tdockerClient, err := d.getDockerClient()\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"Failed to create docker client: %v\", err)\n\t}\n\n\tdockerInfo, err := dockerClient.Info(d.ctx, mclient.InfoOptions{})\n\tif err != nil {\n\t\treturn nil, nil, fmt.Errorf(\"failed to fetch docker daemon info: %v\", err)","sourceCodeStart":324,"sourceCodeEnd":360,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/drivers/docker/driver.go#L324-L360","documentation":"The Docker driver requires an image name to run a container. After decoding the driver config, StartTask checks TaskConfig.Image and returns this error if it is empty, since a container cannot be created without a base image.","triggerScenarios":"A docker task's driver config block omits the 'image' field entirely, or sets it to an empty string (image = \"\"), so driverConfig.Image == \"\" after DecodeDriverConfig.","commonSituations":"Hand-written job specs where the image line was deleted or commented out; templating tools rendering an empty image variable (e.g. ${image_version} unset); programmatic job construction that leaves TaskConfig.Image zero-valued; pasting a config from another driver (raw_exec/exec) that has no image field.","solutions":["Add an image field to the task's docker config block, e.g. image = \"nginx:1.25\"","If the image is templated, ensure the template variable resolves to a non-empty value before job submission","Run nomad job validate to catch the missing image before dispatch","If constructing jobs in code, set the Image field on the docker TaskConfig explicitly"],"exampleFix":"// before\ntask \"web\" {\n  driver = \"docker\"\n  config {\n    # image line missing\n    port_map { http = 80 }\n  }\n}\n// after\ntask \"web\" {\n  driver = \"docker\"\n  config {\n    image = \"nginx:1.25\"\n    port_map { http = 80 }\n  }\n}","handlingStrategy":"validation","validationCode":"// pre-flight check before submit\nif img, _ := cfg[\"image\"].(string); img == \"\" {\n    return errors.New(\"docker driver requires non-empty config.image\")\n}","typeGuard":"func hasImage(cfg map[string]interface{}) bool {\n    img, ok := cfg[\"image\"].(string)\n    return ok && strings.TrimSpace(img) != \"\"\n}","tryCatchPattern":"if _, _, err := driver.StartTask(cfg); err != nil {\n    if err.Error() == \"image name required for docker driver\" {\n        return fmt.Errorf(\"task %q: add config { image = ... } to the docker task\", cfg.ID)\n    }\n    return err\n}","preventionTips":["Always set image in every docker task config block","When templating, fail the render if image variables are empty","Add a CI lint asserting docker tasks have a non-empty image","nomad job validate catches this before dispatch — run it in pipelines"],"tags":["docker","nomad-driver","missing-config","image"],"backgroundTag":"missing-required-argument","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"}