Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Docker-in-docker allow two devcontainers' sub-containers to speak

Aperta
#1,135 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 5 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
docker, docker-compose
Ambito
devops, networking

Direzione di ricerca

Inizia leggendo la documentazione delle funzionalità docker-in-docker e docker-outside-of-docker, quindi esamina le due configurazioni devcontainer.json e i relativi file docker-compose.yaml. Riproduci le due configurazioni di rete annidate e verifica se i container riescono a risolvere o raggiungere l’altro devcontainer; il lavoro è completato quando il container frontend può raggiungere il backend sulla porta 8080 senza impostazioni di rete incorporate specifiche del progetto.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

I'm using the docker-in-docker feature to spin up some containers specific to a project, from within a dev container. I have two projects (frontend and backend) both in separate dev containers both using docker-in-docker and in both of them, I have a docker-compose.yaml file that defines how each service is run (there's databases etc).

flowchart LR
    subgraph My Machine
    A[VSCode]
    end

    A-->|SSH| B[VSCode Remote Host w/Docker]
    B --> C["DevContainer (Frontend)<br>D-in-D<br>172.17.0.2"] --> C1["Container<br>(Frontend :3000)<br>172.18.0.2"]

    B --> D["DevContainer (Backend)<br>D-in-D<br>172.17.0.3"] --> D1["Container<br>(Backend :8080)<br>172.18.0.2"]
    D1--> D2[DB Container A]
    D1--> D3[DB Container B]

How can I have the container running the frontend, get to the container running the backend (port 8080)? For context it's a Nuxt SSR application, so it has its own "server" process meaning the container (not my local browser) needs to see the backend.

I've tried docker-outside-of-docker but vscode seems to not care about the ports, and let me get to them locally (i.e. open my browser for the frontend) as they don't start "inside the devcontainer" so it can't see them. With docker-in-docker, the ports (3000 and 8080) are detected by VSCode, and I can get to them in my browser.

It seems that the devcontainer's IP address exposes the ports, which I can use in the child containers to directly reference the other devcontainer however this would require baking in some network config to the devcontainer.json which I'm attempting to avoid (might be unavoidable at this point). In the diagram above that is requesting http://172.17.0.3:8080 from within the frontend container. Both child containers' networks seem isolated from each other (same IP, different container) but I can't seem to give them an IP on the 172.17.x.x subnet. DNS resolution also doesn't work.

Thanks in advance 😄

Lingua principale
Shell
Stelle
1.5k
Fork
624
Merge medio
4g 8h
PR unite (30g)
7

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di devcontainers/features

Tutte le issue di devcontainers/features

Issue simili

Altre issue su Shell/Bash

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.