Devcontainer WITH docker compose?
So I'm evaluating Coder as a tool for my team to be able to quickly spin up dev envs, but I've been having a hell of a time getting a repo using a devcontainer WITH docker-compose to work on an EC2 runner. I need that so that I can host postgres, opensearch, and all the other services my app needs to run.
Is there any guidance/templates for this? It seems like the official EC2 devcontainer template uses envbuilder which doesn't support docker compose?
9 Replies
<#1438964477382099126>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
I had assumed you could, but now that I am review this: https://github.com/coder/envbuilder/issues/236 - it seems like its been an ask, but they are saying to allow docker-compose would mean to completely revamp envbuilder
GitHub
devcontainer: support docker-compose · Issue #236 · coder/envbui...
Devcontainer spec supports specifying a compose file e.g. "dockerComposeFile": "docker-compose.yml", Example: https://github.com/BrunoQuaresma/openticket/blob/main/.devcontainer...
Yeah that’s what I saw as well, I would love envbuilder to work for this, but I’m also happy to not use it and just do it myself in the VM. But that has proved to be a pain and I can’t find any example templates for this sadly
Main pain point is getting all of the dependencies to actually run the docker compose, and the getting the coder agent to actually work with/inside the dev container
Seems like just endless install script issues
Once I start getting further into building out the POCs I will also look into how this can be solved. But if you find a solution before hand would love to take a look.
Hey 👋 We support Dev Containers without envbuilder as well
Unfortunately our documentation here isn't brilliant. You'll see our support of Dev Containers without envbuilder as "Dev Container Integration".
We use this feature in our dogfooding template:
https://github.com/coder/coder/blob/main/dogfood/coder/main.tf#L642-L646
We have tested this integration and it does support docker compose
To give a quick short summary of what is required:
- Your EC2 image needs to have docker and the dev container CLI installed
- Your template should define a
coder_devcontainer resource
The second point is technically optional because we automatically detect running dev containers as wellHuh okay, cool thanks! Trying this out and I'm getting the devcontainer to popup but then I see an error that my workspace is unhelathy. This is my config https://gist.github.com/harrismcc/d693fd50e17e943379dcc6459769cddf. Any ideas? Is there a way I can see better logs for this? The setup script is finishing alright as far as I can tell, so it's something about building/booting up the devcontainer

Okay I was able to get this working with some messing around! I updated the gist. But now I have to figure out a caching strategy or something because it take >5 minutes to build the devcontainer and pull down all of the docker layers...
The Dev Container website has a section on "prebuilding" dev containers that might be able to help you:
https://containers.dev/guide/prebuild