devcontainers / templates

Repository for Dev Container Templates that are managed by Dev Container spec maintainers. See https://github.com/devcontainers/template-starter to create your own!
https://containers.dev/templates
MIT License
1.03k stars 263 forks source link

Docs about templates usage and behavior #237

Closed ultrasimulation closed 9 months ago

ultrasimulation commented 9 months ago

I searched troughout the documentation on: https://containers.dev/features https://github.com/devcontainers/features

And I can't find detailed instructions on how to use a template. Specifically I would like to use on of it with GitHub Codespaces.

I see that every template in this repository is published as a Package in the 'devcontainer' organization.

Given a template (i.e. https://github.com/devcontainers/templates/tree/main/src/dotnet-mssql). How do I use it?

1) Do I need to create a copy of the files of the entire folder in my repository? 2) Since it is published as a package, can I reference it in my '.devcontainer/devcontainer.json' like images and features? 3) How to pass a parameter for options like 'imageVariant'?

I think that in order to incentivize usage this must be documented.

Thank you

samruddhikhandale commented 9 months ago

Hi 👋

Thank you so much for pointing out the gap in our documentation and I apologize for the inconvenience.

For adding Templates hosted by this repository (as well as the community templates) refer to the Codespaces documentation in https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#using-a-predefined-dev-container-configuration.

I will keep this issue open for tracking documentation changes.

ultrasimulation commented 9 months ago

Hello @samruddhikhandale thank you for pointing to that docs. But i still need answers to that questions so I don't know what to write in the docs 😊.

The main question is "How devcontainer templates must be used both in GH Codespaces that locally". Given this: https://github.com/devcontainers/templates/tree/main/src/dotnet-mssql, should I:

1) Clone the entire folder in my repo or reference it somehow in '.devcontainer/devcontainer.json' like I do with images and features by pulling it from the package registry associated to this repo? Otherwise what is the sense of have it packaged here: https://github.com/devcontainers/templates/pkgs/container/templates%2Fdotnet-mssql ? 3) How to pass parameters like 'templateOption:imageVariant'?

I am not able to find it as template for GH Codespaces. https://github.com/codespaces/templates

Tank you. Hope my request is clear

samruddhikhandale commented 9 months ago

@ultrasimulation I have opened https://github.com/devcontainers/templates/pull/241 which should answer your questions. (Option 2 is what you are looking for, it uses the devcontainers/cli)

Let me know if you have any feedback, thanks!

ultrasimulation commented 9 months ago

It's exactly what I was looking for. Thank you!