Open plangin opened 3 months ago
hostname is forced to be the name of the container because otherwise it makes a lot of things confusing - that is the intended behaviour
EDIT: sorry closed the issue too fast, could you send the compose you are using so I can try reproduce the issue?
send the compose you are using so I can try reproduce the issue?
Sure:
services:
mosquitto:
container_name: mosquitto
image: eclipse-mosquitto:2
hostname: mosquitto
restart: unless-stopped
ports:
- "1883:1883"
When importing this Docker Compose snippet, the Cosmos Compose seems to recognize and apply the desired hostname correctly when clicking on Next:
{
"services": {
"mosquitto": {
"container_name": "mosquitto",
"image": "eclipse-mosquitto:2",
"hostname": "mosquitto",
"restart": "unless-stopped",
"ports": [
"1883:1883"
],
"network_mode": "cosmos-mosquitto-default"
}
},
"networks": {
"cosmos-mosquitto-default": {}
}
}
But on the end, the resulting hostname was d329d1f3a41a, not mosquitto.
Technical background:
I prefer to use self-explanatory and static hostnames, so I can connect effortless to them. In that example I use Home Assistant, Zigbee2MQTT and other MQTT clients with the host 'mosquitto'.
Tried it and it works with no issues on my end, my guess is you have something else (Unraid? Portainer?) that meddles with your container, because when you re-create container in docker, it re-assigns the hostname to some random BS (Docker quirks)
That said, Cosmos is supposed to prevent Docker from doing this (yeah it's nice like that! But only if you recreate from Docker itself) but it's not working in this case because the container is not in bridge mode. So I will adjust the code
Tried it and it works with no issues on my end, my guess is you have something else (Unraid? Portainer?) that meddles with your container
Nope, just NixOS and Cosmos Server was the first container I deployed on Docker.
because when you re-create container in docker, it re-assigns the hostname to some random BS
Aaah, re-creation seems to lead to this issue. I was able to scramble the hostname by just re-creating the container directly within Cosmos
Aaah, re-creation seems to lead to this issue. I was able to scramble the hostname by just re-creating the container directly within Cosmos
Yes that is fixed in the 0.16 branch now
What happened?
When I import a docker compose, the hostname is ignored.
It could look like this:
Instead the hostname pihole, Cosmos Server creates some hostname like 97eb67d37625
Excerpt of generated Cosmos Compose:
What should have happened?
Create a new container with the hostname pihole.
How to reproduce the bug?
Relevant log output
No response
Other details
No response
System details