Is this even possible with docker? (Network Question)

Hello everyone, I’ve been doing a bunch of research to achieve the following:

  • Run dnscrypt-proxy in separate docker container (Container A)
    image => dnscrypt-proxy

  • Run jdownloader in separate docker container (Container B)
    image => jdownloader2

  • Use dnscrypt-proxy container to resolve requests from jdownloader container

Container A:
Container B:

As I understand it, the dnscrypt proxy is located at on Container A.

I have discovered two possible solutions.

  • Using --add-host host.docker.internal:host-gateway on Container A and a custom bridge on Container B
  • Forwarding traffic on and exposing 53/UDP on Container B

Is there a better way to achieve this? Maybe by combining dnscrypt and jdownloader in one single image?

You can hook containers into the network namespace of other containers.

Just use --network container:{container name of dnscryt} to hook the jdownloader container into the network namespace of dnscrypt. As a result both will share the same network interfaces (and yes, localhost inside the jdownloader will be the same localhost as in the dnscrypt container).

Note: ports need to be published on the dnscrypt container, regardless whether they are for dnscrypt or for jdownloader or whatever other container you hook into the network namespace.