Closed carlgleisner closed 3 weeks ago
I'm not in a dev container, but am using network_mode: service:foo
on the container I am targeting and indeed I get this same error.
Could you please run docker network ls
and verify that you have a network named devcontainer_network ?
Docker compose usually adds prefix to networks, so I think it's likely that this is not really the name of your network.
Try giving it a name as:
networks:
devcontainer_network:
name: devcontainer_network
external: true
Thanks for commenting @lucaslorentz 🙏🏻
I won't be able to test this anytime soon due to limited bandwidth, but I very much want to. I'll close the issue with this comment so that it's not left open.
Dear all 👋🏻
I'm trying to set up Dev Containers for a multitenant application with Caddy in front for local HTTPS and handling arbitrary subdomains.
I'd like to think that this would be a pretty appealing setup? 🤔 Haven't found any other reference projects or mentions, so I guess I'm totally off here. Still... would be sweet wouldn't it?
The Gist
Where I'm at is that I've successfully had
caddy-docker-proxy
doing arespond "Hello world"
givendevcontainer.localhost
(defined inHosts
file) using labels from the Dev Container. However, trying to usecaddy.reverse_proxy: "{{upstreams 4000}}"
gives me aContainer is not in same network as caddy
message in thecaddy-docker-proxy
container.The Setup
The Docker-Caddy-Proxy
docker-compose.yml
.Please note that the network name used here is
devcontainer_network
.The
devcontainer_network
is created by the Dev Containerdocker-compose.yml
using the default network name:Attempting a
curl -v https://devcontainer.localhost
from my host gives me a"Container is not in same network as caddy"
.Please note that the way Dev Containers are set up according to the documentation is using
network_mode: service:db
. I have tried creating networks such ascaddy
withdocker network create caddy
but haven't gotten that working with the communication between thedevcontainer
service and thedb
service above. I get the sense thatnetwork_mode: service:db
is the supported way of doing networking with Dev Containers and have tried to stay with that.Also please note that I've tried shutting everything down and doing a
docker system prune -a
before starting up again, but to no avail.If anyone is interested in supporting this effort I'd be most grateful. I don't expect anyone to help out, but if there's interest, perhaps there's something of value to the community 🙂