Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networking between 2 Devcontainer setups #538

Open
AchimGrolimund opened this issue Jan 5, 2025 · 0 comments
Open

Networking between 2 Devcontainer setups #538

AchimGrolimund opened this issue Jan 5, 2025 · 0 comments

Comments

@AchimGrolimund
Copy link

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:

// 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:

// 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant