DNS
The DNS server is embedded in the simplecontainer agent. It is a fully functional DNS server. The port it uses is 53 and is exposed in the Docker network where the simplecontainer is running.
All containers started with the simplecontainer are configured to use DNS server from the simplecontainer agent.
It is aware of all the containers running on the single Docker host and makes service discovery enabled.
Format of the DNS:
network.group.generatedName.cluster
Where:
network
is the network name of the Docker network where the container is deployedgroup
is the group of the container defined in the metageneratedName
is the name generated using container specificationgroup-name-index
.cluster
is the suffix inside the simplecontainer network
When the container is created the respective DNS name is added as the A record in the server. Also, when the container is removed, stopped, or dead the DNS recorded is removed hence the name resolution will fail.
Example single node mode
Let's examine the next minimal container definition:
kind: container
meta:
group: example
name: test
spec:
container:
image: busybox
tag: latest
replicas: 2
entrypoint: ["sleep"]
args: ["3600"]
If no network block is specified container will be added to the bridge network.
This will create three DNS records:
bridge.example.example-test-1.cluster.private
bridge.example.example-test-2.cluster.private
bridge.example.test.cluster.private
The first two DNS records will return the IP of the specific container. The last record will return the IP addresses of both containers.
The records will be live in the DNS server only when the container reaches the RUNNING state otherwise, the DNS record will be discarded.
Example cluster mode
This example assumes there are two nodes in the cluster.
kind: container
meta:
group: example
name: test
spec:
container:
image: busybox
tag: latest
replicas: 2
entrypoint: ["sleep"]
args: ["3600"]
spread:
spread: uniform
networks:
- group: smr
name: cluster
- gorup: docker
name: bridge
This will deploy one container on Node 1 and one container on Node 2.
This will create three DNS records:
cluster.example.example-test-1.cluster.private
cluster.example.example-test-2.cluster.private
cluster.example.test.cluster.private
The first two DNS records will return the IP of the specific container. The last record will return the IP addresses of both containers.
The records will be live in the DNS server only when the container reaches the RUNNING state otherwise, the DNS record will be discarded.
Even if containers are not on the same node DNS will be able to resolve and communication is done via overlay network between two containers.