DEV Community

Fabian Jevon
Fabian Jevon

Posted on

How to generate devcontainer.json automatically without using devcontainer.ai

I want to share my troubleshooting experience when creating a sample project for https://www.daytona.io/.

Problem Background

I need a valid devcontainer.json to run daytona properly but I don't have experience in writing devcontainer configuration & (in that moment) https://devcontainer.ai/ can't generate one for me.

The Solution

I found the alternative way to generate it using VSCode IDE.

  1. Install VSCode Plugin named Dev Containers Image description
  2. Open Command Palette (default shortcut: Ctrl+shift+P)
  3. Search for Dev Containers: Add Dev Container Configuration Files then select it Image description
  4. Choose Add configuration to workspace Image description
  5. Choose the configuration template. In my case, because I'm building a project using Laravel, I choose PHP for the configuration template then choose the default for the PHP version. Image description Image description
  6. Choose the additional features to install. In my case, I need Node.js (via NPM) installed to support my Laravel project then keep defaults Image description
  7. Choose optional File / directories. In my case, I don't need additional file / directories Image description
  8. And.. Voila! A fresh devcontainer.json has been generated for you. Image description

I found this method is very beginner friendly to those who don't have experience in writing devcontainer configuration because the generated config file has several informative comments in it so it can helps we learn

Top comments (1)

Collapse
 
betterslip profile image
BetterSlip

Good post!