|
| 1 | +--- |
| 2 | +display_name:Tasks on Docker |
| 3 | +description:Run Coder Tasks on Docker with an example application |
| 4 | +icon:../../../../.icons/tasks.svg |
| 5 | +verified:false |
| 6 | +tags:[docker, container, ai, tasks] |
| 7 | +--- |
| 8 | + |
| 9 | +#Run Coder Tasks on Docker |
| 10 | + |
| 11 | +This is an example template for running[Coder Tasks](https://coder.com/docs/ai-coder/tasks), Claude Code, along with a[real world application](https://realworld-docs.netlify.app/). |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +This is a fantastic starting point for working with AI agents with Coder Tasks. Try prompts such as: |
| 16 | + |
| 17 | +- "Make the background color blue" |
| 18 | +- "Add a dark mode" |
| 19 | +- "Rewrite the entire backend in Go" |
| 20 | + |
| 21 | +##Included in this template |
| 22 | + |
| 23 | +This template is designed to be an example and a reference for building other templates with Coder Tasks. You can always run Coder Tasks on different infrastructure (e.g. as on Kubernetes, VMs) and with your own GitHub repositories, MCP servers, images, etc. |
| 24 | + |
| 25 | +Additionally, this template uses our[Claude Code](https://registry.coder.com/modules/coder/claude-code) module, but[other agents](https://registry.coder.com/modules?search=tag%3Aagent) or even[custom agents](https://coder.com/docs/ai-coder/custom-agents) can be used in its place. |
| 26 | + |
| 27 | +This template uses a[Workspace Preset](https://coder.com/docs/admin/templates/extending-templates/parameters#workspace-presets) that pre-defines: |
| 28 | + |
| 29 | +- Universal Container Image (e.g. contains Node.js, Java, Python, Ruby, etc) |
| 30 | +- MCP servers (desktop-commander for long-running logs, playwright for previewing changes) |
| 31 | +- System prompt and[repository](https://github.com/coder-contrib/realworld-django-rest-framework-angular) for the AI agent |
| 32 | +- Startup script to initialize the repository and start the development server |
| 33 | + |
| 34 | +##Add this template to your Coder deployment |
| 35 | + |
| 36 | +You can also add this template to your Coder deployment and begin tinkering right away! |
| 37 | + |
| 38 | +###Prerequisites |
| 39 | + |
| 40 | +- Coder installed (see[our docs](https://coder.com/docs/install)), ideally a Linux VM with Docker |
| 41 | +- Anthropic API Key (or access to Anthropic models via Bedrock or Vertex, see[Claude Code docs](https://docs.anthropic.com/en/docs/claude-code/third-party-integrations)) |
| 42 | +- Access to a Docker socket |
| 43 | +- If on the local VM, ensure the`coder` user is added to the Docker group (docs) |
| 44 | + |
| 45 | +```sh |
| 46 | +# Add coder user to Docker group |
| 47 | + sudo adduser coder docker |
| 48 | + |
| 49 | +# Restart Coder server |
| 50 | + sudo systemctl restart coder |
| 51 | + |
| 52 | +# Test Docker |
| 53 | + sudo -u coder docker ps |
| 54 | + ``` |
| 55 | + |
| 56 | + - If on a remote VM, see the [Docker Terraform provider documentation](https://registry.terraform.io/providers/kreuzwerker/docker/latest/docs#remote-hosts) to configure a remote host |
| 57 | + |
| 58 | +To import this template into Coder, first create a template from"Scratch"in the template editor. |
| 59 | + |
| 60 | +Visit this URLfor your Coder deployment: |
| 61 | + |
| 62 | +```sh |
| 63 | +https://coder.example.com/templates/new?exampleId=scratch |
| 64 | +``` |
| 65 | + |
| 66 | +After creating the template, paste the contents from [main.tf](https://github.com/coder/registry/blob/main/registry/coder-labs/templates/tasks-docker/main.tf) into the template editor and save. |
| 67 | + |
| 68 | +Alternatively, you can use the Coder CLI to [push the template](https://coder.com/docs/reference/cli/templates_push) |
| 69 | + |
| 70 | +```sh |
| 71 | +# Download the CLI |
| 72 | +curl -L https://coder.com/install.sh| sh |
| 73 | +
|
| 74 | +# Log in to your deployment |
| 75 | +coder login https://coder.example.com |
| 76 | +
|
| 77 | +# Clone the registry |
| 78 | +git clone https://github.com/coder/registry |
| 79 | +cd registry |
| 80 | +
|
| 81 | +# Navigate to this template |
| 82 | +cd registry/coder-labs/templates/tasks-docker |
| 83 | +
|
| 84 | +# Push the template |
| 85 | +coder templates push |
| 86 | +``` |