Docker --hostname

Botched1

Cadet
Joined
Apr 10, 2022
Messages
4
I think I already know the answer to this (no), but...

Is there any way to set a hostname on a docker container (equivalent to --hostname MyHostName)? I would guess since Kubernetes doesn't work that way, they you can't, but thought I would ask.

It becomes an issue on dockers that require licensing - like Duplicacy. It ties the license to the HOSTNAME of the container and a machine-id. The id stays static, but the hostname will change any time the container is recreated - which would kill the license.

I have a backup plan if it can't be done, but would rather do it as a container on my truenas scale server.
 

Botched1

Cadet
Joined
Apr 10, 2022
Messages
4
For example, if I make a Duplicacy container, I se in the logs:

2022/04/10 20:32:52 A new license has been downloaded for duplicacy-ix-chart-5998df44f6-nc2sc

That is the part that in a perfect world I would be able to keep constant, even through container image upgrades, etc.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703

Botched1

Cadet
Joined
Apr 10, 2022
Messages
4
I did read through that, but I don't THINK it helps for my issue (unless I'm missing something obvious). The issue isn't a pod referencing another pod, it is rather that the pod itself needs a consistent name - which it doesn't in between restarts.

As it is today every time the docker container is restarted it is getting a new internal name, which kills the licensing.

Start container:
2022-04-11 13:30:34.359053+00:002022/04/11 08:30:33 A new license has been downloaded for duplicacy-ix-chart-5998df44f6-8cp4h

Stop and restart container:
2022-04-11 13:32:20.529091+00:002022/04/11 08:32:19 A new license has been downloaded for duplicacy-ix-chart-5998df44f6-8p8xs

Notice the last part is the random portion of the pod name. I don't "think" I can control that, though?
 

HarryMuscle

Contributor
Joined
Nov 15, 2021
Messages
161
I've looked into this before and unfortunately never found a solution. The closest you get is having consistent names for the service in front of the pod (that's what that link talks about) but not the actual pod itself.

Thanks,
Harry
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
I've looked into this before and unfortunately never found a solution. The closest you get is having consistent names for the service in front of the pod (that's what that link talks about) but not the actual pod itself.

Thanks,
Harry

A service can be made to forward all sorts of traffik without issues. (there are options to customise that within our expert and advanced settings sections). It's simply how kubernetes works

For example, if I make a Duplicacy container, I se in the logs:

2022/04/10 20:32:52 A new license has been downloaded for duplicacy-ix-chart-5998df44f6-nc2sc

That is the part that in a perfect world I would be able to keep constant, even through container image upgrades, etc.

Generally speaking:
Anno 2022, this just shows the developer of the Application is an absolute moron.
Sadly enough: There is nothing we can do to fix peoples brains and this is not the only program that has issues related to unskilled developers, this includes software that is said to be "business grade".
 

Kuki_zfs

Cadet
Joined
Dec 2, 2021
Messages
7
Generally speaking:
Anno 2022, this just shows the developer of the Application is an absolute moron.
Sadly enough: There is nothing we can do to fix peoples brains and this is not the only program that has issues related to unskilled developers, this includes software that is said to be "business grade".
There is an easy workaround for this issue, sadly ix's implementation of kubernetes is quite lack-luster.
You could just create the container as statefulSet, and keep the scaling to 1.
The hostname would then always be ix-duplicacy-0. But until ix fix their WebUI to fulfill basic kubernetes needs, we won't be able to do this.

Just let us use Rancher or sth...
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
There is an easy workaround for this issue, sadly ix's implementation of kubernetes is quite lack-luster.
You could just create the container as statefulSet, and keep the scaling to 1.
The hostname would then always be ix-duplicacy-0. But until ix fix their WebUI to fulfill basic kubernetes needs, we won't be able to do this.

Just let us use Rancher or sth...

There is nothing wrong with the kubernetes implementation, in this regard.
We already support this on their platform for a year by now and a lot of our Apps already run as Statefull sets.
 

Kuki_zfs

Cadet
Joined
Dec 2, 2021
Messages
7
There is nothing wrong with the kubernetes implementation, in this regard.
We already support this on their platform for a year by now and a lot of our Apps already run as Statefull sets.
Well, ok let me put it this way. ix's UI does not allow the use of statefulsets, other than helmcharts.
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
Well, ok let me put it this way. ix's UI does not allow the use of statefulsets, other than helmcharts.

iX their UI allows all catalog creators to make use of statefull sets.
It's important to make a clear difference about what iX Allows and what iX Implements in their own catalog.

They indeed do not on their "Launch Docker" implementation, but, incontrast to our custom-app alternative, is not really meant to roll-out kubernetes features and is just meant as a, relatively simple, docker-ish alternative.
 

brunocpt

Cadet
Joined
Feb 27, 2024
Messages
3
I apologize for the newbie and probably stupid question, but how can I define an App as statefull? I'm using the custom-app from truecharts to launch a rabbitmq instance and it seems I can't persist data unless the container name is static.
 

sretalla

Powered by Neutrality
Moderator
Joined
Jan 1, 2016
Messages
9,703
how can I define an App as statefull?
In Kubernetes, containers are stateless.

If you want something to persist between redeployments, you need to use the persistent storage options to make sure that happens... i.e. keep the "data" and "config" outside the container.

it seems I can't persist data unless the container name is static
I can't make any sense out of that...

Are you trying to say that you can't access the persistent storage part of the app config until you give the app a name?
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
I apologize for the newbie and probably stupid question, but how can I define an App as statefull? I'm using the custom-app from truecharts to launch a rabbitmq instance and it seems I can't persist data unless the container name is static.

If you need any help with our Charts and Apps, please reach out to our staff directly.
We sadly enough, do not have to capacity to offer support on third-party forums.
 

brunocpt

Cadet
Joined
Feb 27, 2024
Messages
3
In Kubernetes, containers are stateless.

If you want something to persist between redeployments, you need to use the persistent storage options to make sure that happens... i.e. keep the "data" and "config" outside the container.


I can't make any sense out of that...

Are you trying to say that you can't access the persistent storage part of the app config until you give the app a name?
Sorry if I wasn't clear.

Rabbitmq persists its data in a folder which is created automatically with the hostname - like /var/lib/data/mnesia/rabbit@rabbitmq-modal-custom-app-7ff47f9b47-8lbk4, where "custom-app-7ff47f9b47-8lbk4" is the hostname of the container, that changes at every restart. So, even though I mount a host path dataset as /var/lib/data/mnesia/, the last part is always different at every reboot.

The only way to fix that is to set a static hostname to the container, which is easy in docker-compose, but not on Kubernetes - at least according to various threads I found.
 

truecharts

Guru
Joined
Aug 19, 2021
Messages
788
Sorry if I wasn't clear.

Rabbitmq persists its data in a folder which is created automatically with the hostname - like /var/lib/data/mnesia/rabbit@rabbitmq-modal-custom-app-7ff47f9b47-8lbk4, where "custom-app-7ff47f9b47-8lbk4" is the hostname of the container, that changes at every restart. So, even though I mount a host path dataset as /var/lib/data/mnesia/, the last part is always different at every reboot.

The only way to fix that is to set a static hostname to the container, which is easy in docker-compose, but not on Kubernetes - at least according to various threads I found.

Its often not that hard, either use statefullsets or try mounnting mnesia directly.
We'll leave it at that, feel free to reach out if you need more help with our charts and/or apps
 

brunocpt

Cadet
Joined
Feb 27, 2024
Messages
3
Its often not that hard, either use statefullsets or try mounnting mnesia directly.
We'll leave it at that, feel free to reach out if you need more help with our charts and/or apps
Yes, that seems to be the solution - however, I don't know how to use statefullsets, which was my original question. I appreciate any help in that regard!
 
Top