Can I use Docker in a runner on Nomad?

I have a Waypoint runner task running in a Nomad cluster. I have it watching a remote git repository.

          app "test" {
              build {
                use "docker" {}
              }
              deploy {
                use "docker" {}
              }
          }

When the runner sees a change in the repository and tries to run the build step, it returns an error:

2022-11-03T03:17:08.951Z [WARN]  waypoint.runner.agent.runner: error during job execution:
  job_id=01GGXQW1Y1JETX8T7F1GHFY94G
  job_op=*gen.Job_Up
  err="rpc error:
    code = Internal
    desc = error building image:
      Cannot connect to the Docker daemon at unix:///var/run/docker.sock.
      Is the docker daemon running?"

Can Docker be used in this way? I found a post that mentioned a lack of support for docker-pull in on-demand runners. Perhaps this is related.

Here is my task definition:

    task "runner" {
      driver = "exec"
      lifecycle {
        hook    = "poststart"
        sidecar = "true"
      }
      config {
        command = "/bin/bash"
        args    = ["${NOMAD_TASK_DIR}/waypoint_runner.sh"]
      }
      template {
        destination = "${NOMAD_TASK_DIR}/waypoint_runner.sh"
        perms       = "644"
        data        = <<EOF
          #!/bin/bash
          set -eux

          until [ -s ${NOMAD_ALLOC_DIR}/bootstrap.token ]; do
            sleep 1
          done

          export WAYPOINT_SERVER_ADDR="localhost:{{ env "NOMAD_PORT_server" }}"
          export WAYPOINT_SERVER_TLS=true
          export WAYPOINT_SERVER_TLS_SKIP_VERIFY=true
          export WAYPOINT_SERVER_TOKEN=$(<{{env "NOMAD_ALLOC_DIR"}}/bootstrap.token)
          ${NOMAD_ALLOC_DIR}/waypoint runner agent
        EOF
      }
    }

I switched the task driver to raw_exec and now we are getting somewhere. If I can figure out how the runner is calling docker and what it needs…

[WARN]  waypoint.runner.agent.runner: error during job execution:
  job_id=01GH030JBAHFC2BNXE34C39Z9G
  job_op=*gen.Job_Up
  err="rpc error: code = Internal desc =
    unable to stream build logs to the terminal:
    ADD failed: file not found in build context or excluded
    by .dockerignore: stat workspace/: file does not exist"

Hey there @SunSparc - Do you have any runner profiles? For remote builds, we use Kaniko. If you are getting an error about docker, it’s likely that the job is trying to be executed on the runner agent rather than a remote on-demand runner. This is usually cased by not having a runner profile defined. What is defined when you run waypoint runner profile list? Thank you!