Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: Docker Compose import ignores hostname #289

Open
plangin opened this issue Jul 29, 2024 · 5 comments
Open

[BUG]: Docker Compose import ignores hostname #289

plangin opened this issue Jul 29, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@plangin
Copy link

plangin commented Jul 29, 2024

What happened?

When I import a docker compose, the hostname is ignored.

It could look like this:

services:
  pihole:
    container_name: pihole
    environment:
      FTLCONF_LOCAL_IPV4: 192.168.178.10
      TZ: Europe/Berlin
    hostname: pihole

Instead the hostname pihole, Cosmos Server creates some hostname like 97eb67d37625

Excerpt of generated Cosmos Compose:

      "entrypoint": "/s6-init",
      "hostname": "97eb67d37625",
      "network_mode": "cosmos-pihole-default",

What should have happened?

Create a new container with the hostname pihole.

How to reproduce the bug?

  1. Go to 'ServApps'
  2. Click on 'Import Compose File'
  3. Import some Docker Compose file with hostname information.

Relevant log output

No response

Other details

No response

System details

  • Cosmos v0.15.7
@plangin plangin added the bug Something isn't working label Jul 29, 2024
@azukaar
Copy link
Owner

azukaar commented Jul 29, 2024

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?

@azukaar azukaar closed this as completed Jul 29, 2024
@azukaar azukaar reopened this Jul 29, 2024
@plangin
Copy link
Author

plangin commented Jul 30, 2024

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'.

@azukaar
Copy link
Owner

azukaar commented Aug 1, 2024

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

image

@plangin
Copy link
Author

plangin commented Aug 3, 2024

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

@azukaar
Copy link
Owner

azukaar commented Aug 4, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants