Coder.comC
Coder.com13mo ago
14 replies
Ryan

Intermittent failures in container deletion/creation on remote docker provider

Original message: https://discord.com/channels/747933592273027093/971231372373033030/1323039264778223657

Other relevant info (while I don't have logs handy):

provider config:
provider "docker" {
  host = "ssh://user@host"
  ssh_opts = ["-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "/path/to/key"]
}


and just in case this is relevant: all my affected docker_containers depend on a null_resource that ssh's into the remote host and instantiates some local seed data to a persistent volume if this is the first time this workspace has ever been started (as far as I can tell this part never fails):

resource "null_resource" "prepopulate_db_data" {
  count = data.coder_workspace.me.start_count
  provisioner "remote-exec" {
    connection {
      type = "ssh"
      user = "user"
      private_key = file("/path/to/key")
      host = "host"
      agent = false
      timeout = "90s"
    }

    inline = [
      "docker run --rm -v /root/dev_data:/dev_data -v ${docker_volume.db_data.name}:/data alpine sh -c 'if [ ! -f /data/.initialized ]; then cp -r /dev_data/db_data/* /data/; touch /data/.initialized; fi'"
    ]
  }

  depends_on = [docker_volume.db_data]
}
Was this page helpful?