Files
coder/examples/templates/docker
David Wahler f7ea016494 Pass git configuration variables via terraform (#3034)
* Pass workspace owner email address to provisioner

* Remove owner_email and owner_username fields from agent metadata

* Add Git environment variables to example templates

* Remove "owner_name" field from provisioner metadata, use username instead

* Remove Git configuration from most templates, add documentation

* Proofreading/typo fixes from @mafredri

* Update example templates to latest version of terraform-provider-coder
2022-07-19 13:24:06 -05:00
..

name, description, tags
name description tags
Develop in Docker Run workspaces on a Docker host using registry images
local
docker

docker

To get started, run coder templates init. When prompted, select this template. Follow the on-screen instructions to proceed.

Adding/removing images

After building and pushing an image to an image registry (e.g., DockerHub), edit the template to make the image available to users:

# Open the template
vim main.tf

Modify your file to match the following:

variable "docker_image" {
  description = "What Docker image would you like to use for your workspace?"
  default     = "codercom/enterprise-base:ubuntu"
  validation {
    condition     = contains(["codercom/enterprise-base:ubuntu", "codercom/enterprise-node:ubuntu",
-                              "codercom/enterprise-intellij:ubuntu"], var.docker_image)
+                              "codercom/enterprise-intellij:ubuntu", "codercom/enterprise-golang:ubuntu"], var.docker_image)
    error_message = "Invalid Docker image!"
  }
}

Update the template:

coder template update docker

You can also remove images from the validation list. Workspaces using older template versions will continue using the removed image until you update the workspace to the latest version.

Updating images

To reduce drift, we recommend versioning images in your registry by creating tags. To update the image tag in the template:

variable "docker_image" {
  description = "What Docker image would you like to use for your workspace?"
  default     = "codercom/enterprise-base:ubuntu"
  validation {
-    condition     = contains(["my-org/base-development:v1.1", "myorg-java-development:v1.1"], var.docker_image)
+    condition     = contains(["my-org/base-development:v1.1", "myorg-java-development:v1.2"], var.docker_image)

    error_message = "Invalid Docker image!"
  }
}

Optional: Update workspaces to the latest template version:

coder ls
coder update [workspace name]

Extending this template

See the kreuzwerker/docker Terraform provider documentation to add the following features to your Coder template:

  • SSH/TCP docker host
  • Registry authentication
  • Build args
  • Volume mounts
  • Custom container spec
  • More

We also welcome contributions!