Hi,
I have a nomad cluster with a consul Mesh network. I use RabbitMQ docker (in Mesh network) that needs to have a constant hostname because the persistence is based on the hostname of the docker. The node storage name is linked to the hostname of the rabbitMQ instance. If the hostname is not the same, the storage can’t be used so it is a problem after a restart with a new random name. It seems to be not possible to have a hostname with bridge mode. Is there any solution to have a deterministic hostname in bridge mode with nomad ?
@babohot474, are you setting the hostname
in the network
block?
1 Like
I had to solve a similar problem recently.
If I remember well, In order to set the hostname of the docker container I had to do following steps:
@seth.hoenig I used the hostname option in the docker config block. With the hostname option in network, it seems to work correctly. Thanks for your help !
@teymour It not works in docker config block even if I have CNI plugins.
Ah I see. Glad you solved it!
Though am curious why it is different for you. I had to set the hostname for minio to recognize the “localhost” and used this config
config {
image = "minio/minio"
ports = ["api", "dashboard"]
network_mode = "network_using_host_dns"
hostname = "minio-${node_number}.service.consul"
args = [
"server",
"http://minio-{0...3}.service.consul:9001/minio-data",
"--address", ":9001",
"--console-address", ":9090"
]
}
Maybe because I am using a userspace network? (I had issues using the host DNS with the default docker network)
Or maybe due to consul meshing (not familiar with it)?
I have the following error when I have the hostname option in config:
conflicting options: hostname and the network mode
I have the problem even if my service is outside the mesh network (my network config is basic: network {mode = "bridge"}
so I suppose the problem is correlated with network_mode = "network_using_host_dns"
or userspace net.