Coder.comC
Coder.com4y ago
66 replies
matifali

Mount a Host folder as a volume

I am trying to mount a host folder /data/atif inside my workspace using the following settings.
resource "docker_container" "workspace" {
  count = data.coder_workspace.me.start_count
  image = docker_image.coder_image.latest
  cpu_shares = var.cpu
  memory = "${var.ram*1024}"
  runtime = "nvidia"
  gpus = "all"
  # Uses lower() to avoid Docker restriction on container names.
  name = "coder-${data.coder_workspace.me.owner}-${lower(data.coder_workspace.me.name)}"
  # Hostname makes the shell more user friendly: coder@my-workspace:~$
  hostname = lower(data.coder_workspace.me.name)
  dns      = ["1.1.1.1"]
  # Use the docker gateway if the access URL is 127.0.0.1
  command = ["sh", "-c", replace(coder_agent.dev.init_script, "127.0.0.1", "host.docker.internal")]
  env     = ["CODER_AGENT_TOKEN=${coder_agent.dev.token}"]

  host {
    host = "host.docker.internal"
    ip   = "host-gateway"
  }
  volumes {
    container_path = "/home/${data.coder_workspace.me.owner}/"
    volume_name    = docker_volume.home_volume.name
    host_path      = "/data/${data.coder_workspace.me.owner}/"
    read_only      = false
  }
}


But I am not seeing anything inside my workspace /home/atif/

What I am doing wrong.
The folder already exists on the docker host and have some sub directories and files.
Was this page helpful?