Let’s say we have two docker containers, each with net=none (internal network, not exposed to host or each other). Is it possible to link ports for say a mail services (maybe port 25, 143 an so on)?
So you could run each instance without internet access and without exposing ports to the host. But on the other hand you can link both instances and use the mail services inside container 2 from container 1.
Container 1: Contains Web app and a mail client like thunderbird (that mail client can be run via xhost + on the x server of the host machine).
Container 2: Contains SMTP Server and IMAP Server, all dedicated ports are reachable from Container 1 and Container 2. But not from the host or the internet.
That would be awesome for creating a perfect staging area for some kind of projects where you can debug the web app and examine sent emails.
Is port linking between containers with just “internal networking” possible?
Update: I solved it by starting container 2 (named mailtest) with net=none and then starting container 1 with net=container:mailtest. So both are not completely isolated from the internet / host. But they share the network stack of container 2, that is all I need. RTFM helped me. I can connect now port 25 on localhost from within container1! Cool!
Start mailtest container2:
docker run --net=none --name mailtest -i -t davert/mailserver:latest /bin/bash
Then start the sandbox container1 containing the web app:
docker run --net=container:mailtest --name sandbox -i -t arch:sandbox /bin/bash