# New Cluster in Docker - how to generate Cluster\_ID

**URL:** <https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346>\
**Category:** Ops\
**Created:** [11 October 2024 12:09 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346 "2024-10-11T12:09:03Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [11 October 2024 12:09 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/1 "2024-10-11T12:09:03Z")

</div>

Hi there,

I am quite new to containers & Kafka so excuse my very basic question (s).  
I am trying to set up new 3 node Cluster using the cp community edition.

I struggle with the easy task to generate the CLUSTER\_ID for the KRaft mode.  
The ID is supposed to be generated by

bin/kafka-storage.sh random-uuid

However, as I understand it that is a command inside the kafka docker container.  
Whenever I start the container it exists immediatly since the Cluster\_ID is not set, so I dont have a chance to create it and format storage.

I am sure I must be missing something very basic, but I can’t seem to find it.

Any help is appreciated,  
Thanks,  
cheers

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [14 October 2024 06:18 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/2 "2024-10-14T06:18:52Z")

</div>

Correction (Can’t seem to edit, sorry):

exit’s (=dies) not exists.

Else this question does not make any sense;)

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [14 October 2024 09:26 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/3 "2024-10-14T09:26:59Z")

</div>

hey @Rand  
welcome 🙂

you need to set the CLUSTER\_ID and pass to the container.

see [Docker Image Configuration Reference for Confluent Platform | Confluent Documentation](https://docs.confluent.io/platform/current/installation/docker/config-reference.html#cp-kafka-example)

best,  
michael

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [14 October 2024 09:57 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/4 "2024-10-14T09:57:34Z")

</div>

Hi Michael,

thanks, I’ve seen that.  
But I cannot execute  
/bin/kafka-storage random-uuid  
inside the docker container since it dies right away and I dont have the binary on the host os since I don’t have Kafka installed.

I sure can use a randomn ClusterID I picked up from the internet to get over that, but then it still dies because the storage is not configured properly.

I assume I am missing something obvious but what?

Is there an option i can pass to prevent the container from dying when kafka cannot start properly?

Thanks,  
cheers

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [14 October 2024 10:31 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/5 "2024-10-14T10:31:28Z")

</div>

hmm strange

what happens if you just use the example from above with the same variables ?

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [14 October 2024 10:51 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/6 "2024-10-14T10:51:09Z")

</div>

Hmm,  
that one stays up.

So that tells me that my custom startup config must be the culprit, thats very helpful.

I’ll simplify mine or rebuild it based on the example

Thanks a lot for that pointer 🙂

Edit :  
But anyhow, what is the envisioned workflow here?

Use a dummy (example) Cluster\_ID to start, then run the commands to create a new one?  
This was somehow missing from the documentation or I didnt unterstand it

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [14 October 2024 12:31 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/7 "2024-10-14T12:31:34Z")

</div>

So,  
first attempt to change things directly causes the next issue -  
I basically replace kafka-kraft with the host/server fqdn and promptly the container crashes with

```auto
[2024-10-14 12:21:32,151] INFO [SocketServer listenerType=CONTROLLER, nodeId=1] Enabling request processing. (kafka.network.SocketServer)
[2024-10-14 12:21:32,154] ERROR Unable to start acceptor for ListenerName(CONTROLLER) (kafka.network.DataPlaneAcceptor)
org.apache.kafka.common.KafkaException: Socket server failed to bind to <fqdn>:29093: Cannot assign requested address.
        at kafka.network.Acceptor.openServerSocket(SocketServer.scala:734)
        at kafka.network.Acceptor.liftedTree1$1(SocketServer.scala:637)
        at kafka.network.Acceptor.start(SocketServer.scala:632)

```

I’ve turned off selinux and firewalld to make sure thats not it, and it works fine with  
the internal hostname, but I dont see why it wont with the actual hostname?  
I found [Kafka Listeners – Explained | Confluent | DE](https://www.confluent.io/de-de/blog/kafka-listeners-explained/) but that didnt help much.  
In our previous (non confluent, zookeeper) deployment we used the fqdn for the listeners just fine…

Thanks

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [14 October 2024 12:47 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/8 "2024-10-14T12:47:43Z")

</div>

I think best way would be the following

` docker run -it --rm confluentinc/cp-kafka kafka-storage random-uuid`

does this work for you?

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [14 October 2024 12:48 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/9 "2024-10-14T12:48:33Z")

</div>

mmh which config did you use?  
the one I’ve shared or something different?

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [14 October 2024 13:11 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/10 "2024-10-14T13:11:42Z")

</div>

> [@mmuehlbeyer](#):
>
> run -it --rm confluentinc/cp-kafka kafka-storage random-uuid

Yes, very good - that would be a helpful command to put in the docs:)

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [14 October 2024 13:17 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/11 "2024-10-14T13:17:35Z")

</div>

> mmh which config did you use?  
> the one I’ve shared or something different?

Hi,

yes the one you shared, put it in a file, ran replace kafka-kraft with fqdn and then it does not start any more  
(and also replace 7.7.1 with latest to be precise)

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [14 October 2024 13:32 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/12 "2024-10-14T13:32:56Z")

</div>

did you also change kafka-kraft for the  
parameter  
`-h <fqdn>`?

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [14 October 2024 13:53 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/13 "2024-10-14T13:53:15Z")

</div>

I tried changeing -h parameter and also leave it out to use the OS hostname

Do you suggest I need to provide a separate (internal) hostname to the container? how would I address that from the other kafka containers if it is not known to DNS  
I looked at the production settings assuming that it might be explained in more detail there but its not mentioned there at all.

Maybe I am missing some basic understanding how the communication works, sorry

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [14 October 2024 14:15 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/14 "2024-10-14T14:15:58Z")

</div>

normally I rely on the OS hostname.

what would you like to achieve ?  
a mulit node docker based setup with CP and KRaft?

best,  
michael

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [14 October 2024 14:18 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/15 "2024-10-14T14:18:37Z")

</div>

a nice tool written by a colleauge might be worth to have a look

> **[How to Create docker-compose.yml File With Kafka Docker Composer | Confluent](https://www.confluent.io/blog/how-to-use-kafka-docker-composer/)**
>
> Learn how to create a docker-compose.yml file for Kafka using Kafka Docker Composer. Set up clusters, perform failover testing, and more with this guide.

> **[GitHub - sknop/kafka-docker-composer: Python script to generate a docker-compose.yaml...](https://github.com/sknop/kafka-docker-composer)**
>
> Python script to generate a docker-compose.yaml file based on templates and parameters

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [15 October 2024 05:53 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/16 "2024-10-15T05:53:17Z")

</div>

> what would you like to achieve ?  
> a mulit node docker based setup with CP and KRaft?

Well, things are a bit more complicated, in the end I need a 3 host setup based on podman to replace our old 3 host ZK based cluster, so the compose file probably wont work. However it should give me an idea on how the options should look like, so I’ll have a look.

Maybe it can shed a light on why the (single, test) container won’t start with hostname. I also will need to get SSL encryption running again.

A separate question - I see that for a production setup it is suggested to separate broker and controller.  
I could split those into two containers on the same host but not sure if thats any better than having them in the same container?.  
If this is really really neccessary I could place them with the application (assuming either’s resource use is small enough) but that would be a last resort option.

We didnt have any issues with the 3 Kafka/ 3 ZK container based setup we had before, availability matters were handled by VMWare.

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [15 October 2024 10:45 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/17 "2024-10-15T10:45:49Z")

</div>

> [@mmuehlbeyer](#):
>
> normally I rely on the OS hostname.

Could you elaborate on that?

Lets say I have a host “dolphin”  
In your linked example would I replace the kafka-kraft name as such?

> **replace kafka\_kraft with dolphin**
>
> docker run -d   
> –name=dolphin\_kafka-kraft   
> -h dolphin   
> -p 9101:9101   
> -e KAFKA\_NODE\_ID=1   
> -e KAFKA\_LISTENER\_SECURITY\_PROTOCOL\_MAP=‘CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT\_HOST:PLAINTEXT’   
> -e KAFKA\_ADVERTISED\_LISTENERS=‘PLAINTEXT://dolphin:29092,PLAINTEXT\_HOST://localhost:9092’   
> -e KAFKA\_JMX\_PORT=9101   
> -e KAFKA\_JMX\_HOSTNAME=localhost   
> -e KAFKA\_PROCESS\_ROLES=‘broker,controller’   
> -e KAFKA\_OFFSETS\_TOPIC\_REPLICATION\_FACTOR=1   
> -e KAFKA\_CONTROLLER\_QUORUM\_VOTERS=‘1@dolphin:29093’   
> -e KAFKA\_LISTENERS=‘PLAINTEXT://dolphin:29092,CONTROLLER://dolphin:29093,PLAINTEXT\_HOST://0.0.0.0:9092’   
> -e KAFKA\_INTER\_BROKER\_LISTENER\_NAME=‘PLAINTEXT’   
> -e KAFKA\_CONTROLLER\_LISTENER\_NAMES=‘CONTROLLER’   
> -e CLUSTER\_ID=‘MkU3OEVBNTcwNTJENDM2Qk’   
> confluentinc/cp-kafka:7.7.1

Or would i just leave the container hostname out?

> **leave the container hostname out**
>
> docker run -d   
> –name=dolphin\_kafka-kraft   
> -p 9101:9101   
> -e KAFKA\_NODE\_ID=1   
> -e KAFKA\_LISTENER\_SECURITY\_PROTOCOL\_MAP=‘CONTROLLER:PLAINTEXT,PLAINTEXT:PLAINTEXT,PLAINTEXT\_HOST:PLAINTEXT’   
> -e KAFKA\_ADVERTISED\_LISTENERS=‘PLAINTEXT://dolphin:29092,PLAINTEXT\_HOST://localhost:9092’   
> -e KAFKA\_JMX\_PORT=9101   
> -e KAFKA\_JMX\_HOSTNAME=localhost   
> -e KAFKA\_PROCESS\_ROLES=‘broker,controller’   
> -e KAFKA\_OFFSETS\_TOPIC\_REPLICATION\_FACTOR=1   
> -e KAFKA\_CONTROLLER\_QUORUM\_VOTERS=‘1@dolphin:29093’   
> -e KAFKA\_LISTENERS=‘PLAINTEXT://dolphin:29092,CONTROLLER://dolphin:29093,PLAINTEXT\_HOST://0.0.0.0:9092’   
> -e KAFKA\_INTER\_BROKER\_LISTENER\_NAME=‘PLAINTEXT’   
> -e KAFKA\_CONTROLLER\_LISTENER\_NAMES=‘CONTROLLER’   
> -e CLUSTER\_ID=‘MkU3OEVBNTcwNTJENDM2Qk’   
> confluentinc/cp-kafka:7.7.1

I tried both and neither is working (container dies) while its working when I dont use the actual hostname in it, but then I don’t see how this would work in a multihost cluster unless I make kafka-kraft or kafka and controller 1-3 from the docker compose generator valid (resolveable) hostnames.

And while I am asking stupid questions - Labels can be adjusted, right?  
So I can replace _PLAINTEXT\_HOST_ with _PLAINTEXT\_dolphin_ to make things clearer?

Thanks & cheers

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [15 October 2024 11:00 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/18 "2024-10-15T11:00:23Z")

</div>

Hi,

let me prep a short example.  
Will come back to you tomorrow, today is a bit packed.

Best,  
Michael

---

<div class="post-metadata">

**Author:** ![mmuehlbeyer](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mmuehlbeyer/32/1088_2.png) [@mmuehlbeyer](https://forum.confluent.io/u/mmuehlbeyer)\
**Post date:** [18 October 2024 06:45 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/19 "2024-10-18T06:45:28Z")

</div>

need to do this during the weekend keep you posted 🙂

---

<div class="post-metadata">

**Author:** ![Rand](https://avatars.discourse-cdn.com/v4/letter/r/ebca7d/32.png) [@Rand](https://forum.confluent.io/u/Rand)\
**Post date:** [24 October 2024 05:14 UTC](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346/20 "2024-10-24T05:14:46Z")

</div>

Just making sure you don’t forget me;)

[Next page](https://forum.confluent.io/t/new-cluster-in-docker-how-to-generate-cluster-id/12346.md?page=2)
