devcontainers / devcontainers/spec

Networking between 2 Devcontainer setups

Open
#538 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
5.7k
Forks
496
PR merge metrics
No merged PRs in 30d

Description

Hello everyone

I have a question regarding networking.

I have 2 projects:
A: Go + PostgreSQL
B: NodeJs + JavaScript

Now I need to get from the frontend to the API in project A. Unfortunately I can't get this done.
Is there a solution how to get 2 DevContainers projects into the same network?

Here are my configs:

Projekt A:
```json
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/go-postgres
{
"name": "Go & PostgreSQL",
"dockerComposeFile": "docker-compose.yml",
"service": "app",
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
"features": {
"ghcr.io/devcontainers/features/git:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers-extra/features/curl-apt-get:1": {}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"christian-kohler.path-intellisense",
"saoudrizwan.claude-dev",
"rooveterinaryinc.roo-cline"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [5432, 8000],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "go mod tidy"

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

```

Projekt B:
```json
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
{
"name": "Node.js",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/javascript-node:1-22-bookworm",
"features": {
"ghcr.io/devcontainers/features/git:1": {}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [4173, 5173],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "npm install",

// Network from Projekt A (Autocreated by Docker Compose)
"runArgs": [ "--network=printstash-api_devcontainer_default" ],

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions": [
"Vue.volar",
"dbaeumer.vscode-eslint",
"EditorConfig.EditorConfig",
"esbenp.prettier-vscode",
"christian-kohler.path-intellisense",
"rooveterinaryinc.roo-cline"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

```

Best Achim

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.