Communication Between Docker Containers - How?

paul56

Dabbler
Joined
Aug 16, 2021
Messages
14
Hi,
Just migrated from Ubuntu for my NAS with SMB shares and docker to TrueNAS SCALE 21.06. Have to say I'm very impressed and had very few issues for something in Beta so thanks to everyone involved.

One query though - I am currently still running some docker containers on SCALE (as these don't yet have a SCALE equivalent). The standalone ones work fine but how do I get them to talk to each other? Under plain docker on Ubuntu they used the container name in the default docker network, but I realise SCALE is using Kubernetes so different. I saw an article that SCALE apps should use a different name to communicate internally - "$NAME.ix-$NAME.svc.cluster.local" but this doesn't seem to work for docker apps.
Should it work and is this a bug or is there a different way to do it for docker containers?
For now I have got around this by putting my mariadb and other docker containers that need to talk to the db on host network and using the host IP for the mariadb name which works fine, except that means they're accessible from my whole LAN and use the native container ports which sometimes overlap, so not ideal.

If someone could explain how docker containers are supposed to talk to each other (without using host network) it would really help, or is internal docker container to docker container connectivity not supported on SCALE so I just need to wait until mariadb and other containers are available as SCALE apps or use a VM for now?

Thanks!
 

waqarahmed

iXsystems
iXsystems
Joined
Aug 28, 2019
Messages
136
@paul56 this works already in the latest nightlies ( using kubernetes internal DNS resolution to access other apps ) and will be available in 21.08 release as well where from the UI you can configure DNS Policy to be "Cluster First" where internal dns resolution of kubernetes will work ;) Please do let us know if you run into issues on that end, thank you!
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
As the $NAME is a direct copy-paste from our documentation, I think we should respond:
The syntax shown in our Docs only applies to TrueCharts. It's not a kubernetes designed format, but one of our own (which we share with the k8s-at-home community)

The fix suggested by @waqarahmed is already implemented in our Apps and we today re-reviewed and updated our linking docs accordingly:
 

paul56

Dabbler
Joined
Aug 16, 2021
Messages
14
I've updated to 21.08 now so going to give this a try.
Can I just check which setting I should use once I turn of host network mode to allow the containers to use the internal network/name resolution to communicate internally instead.
The options are:
1) Default where pod will inherit form the node
2) Kubernetes internal DNS will be prioritised and resolved first If the..<cuts off>
3) For Pods running with hostNetwork and wanting to prioritise internal kubernetes DNS should make use of this policy
4) Ignore DNS from Kubernetes cluster

Would option 2 be best here, or option 3?

For example if I want to connect various docker containers to my mariadb container (named mariadb using default docker image mariadb) I'd use option 2 with this for the DB host variable in the other containers settings: "mariadb.ix-mariadb.svc.cluster.local"?

Thanks!
 
Top