├── .devcontainer ├── node-container │ └── devcontainer.json └── python-container │ └── devcontainer.json ├── LICENSE.txt ├── README.md ├── docker-compose.yml ├── node-src ├── .vscode │ └── launch.json └── hello.js └── python-src └── hello.py /.devcontainer/node-container/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Node Container", 3 | "dockerComposeFile": ["../../docker-compose.yml"], 4 | "service": "app", 5 | "shutdownAction": "none", 6 | "workspaceFolder": "/workspace/node-src" 7 | } 8 | -------------------------------------------------------------------------------- /.devcontainer/python-container/devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Python Container", 3 | "dockerComposeFile": ["../../docker-compose.yml"], 4 | "service": "api", 5 | "shutdownAction": "none", 6 | "workspaceFolder": "/workspace/python-src" 7 | } 8 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | 'Software'), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Working with multiple dev containers in VS Code 2 | 3 | ## Prerequisites 4 | 5 | - [Dev Containers Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers) installed in VS Code. 6 | 7 | ## How to use multiple dev containers in a single VS Code window 8 | 9 | - Open local VS Code window on cloned repo. 10 | - From the command palette `Dev Containers: Reopen in Container`, pick Python Container. 11 | - This will open a new VS Code window connected to the selected container. 12 | - From the command palette `Dev Containers: Switch Container`, pick Node Container. 13 | - This will reload the VS Code window connected to the selected container. 14 | 15 | ## How to use multiple dev containers in a multiple VS Code window 16 | 17 | 1. Open local VS Code window on cloned repo. 18 | 2. From the command palette `Dev Containers: Reopen in Container`, pick Python Container. 19 | 3. This will open a new VS Code window connected to the selected container. 20 | 4. Go to File > New Window. 21 | 5. In this new window, from the command palette `Dev Containers: Reopen in Container`, pick Node Container. 22 | 6. This will open a new VS Code window connected to the selected container. 23 | 24 | ## Additional Resources 25 | 26 | - [Dev Containers Supporting tools and services](https://containers.dev/supporting) 27 | - [Dev Containers Documentation for VS Code](https://code.visualstudio.com/docs/remote/containers) 28 | - [Dev Containers Documentation](https://containers.dev/) -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | api: 4 | image: mcr.microsoft.com/devcontainers/python:1-3.12-bookworm 5 | volumes: 6 | # Mount the root folder that contains .git 7 | - .:/workspace:cached 8 | command: sleep infinity 9 | links: 10 | - app 11 | # ... 12 | 13 | app: 14 | image: mcr.microsoft.com/devcontainers/typescript-node:1-20-bookworm 15 | volumes: 16 | # Mount the root folder that contains .git 17 | - .:/workspace:cached 18 | command: sleep infinity 19 | # ... 20 | -------------------------------------------------------------------------------- /node-src/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Launch Program", 11 | "skipFiles": [ 12 | "/**" 13 | ], 14 | "program": "${workspaceFolder}/hello.js" 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /node-src/hello.js: -------------------------------------------------------------------------------- 1 | console.log("Hello, world!"); 2 | -------------------------------------------------------------------------------- /python-src/hello.py: -------------------------------------------------------------------------------- 1 | print("Hello, world!") --------------------------------------------------------------------------------