How to use confluent CLI with platform running in docker

I have installed the confluent CLI (via brew install confluentinc/tap/cli) and also got a local version of the confluent platform up and running using this cp-all-in-one-kraft docker-compose file.

Now, I want to use the confluent cli tool to control the confluent platform. As far as I understand the documentation, this should be possible - but I failed miserably. I found several posts asking the same question, but none of the answers worked.

  1. I can’t login via confluent login because there is no username and pwd configured.
  2. I can’t login via confluent login --url=... because there is no MDS (Metadata Service) running.
  3. I can’t use confluent kafka topic create "test-topic" --url http://localhost:8082 --no-authentication (as mentioned here: Connecting confluent CLI to confluent platform locally - #2 by krishna), because neither --url nor --no-authentication are supported (confluent issues an error message).
  4. Not logging in doesn’t work either, confluent kafka topic create "test-topic" results in Error: not logged in.

I’m lost - how am I supposed to use the cli? Any help is highly appreciated.

BTW, it works perfectly when connecting to the confluent cloud.
I’m running

  • MacOS 14.4.1 (M1)
  • confluent cli version 3.60.0

I suspect that the CLI is still in Confluent Cloud mode because you are still logged in. If you run confluent logout then this command will succeed.

Here are commands to create a topic, produce, and consume against cp-all-in-one-kraft:

$ confluent kafka topic create test_topic --url http://localhost:8082 --no-authentication
Created topic "test_topic".

$ confluent kafka topic produce test_topic --bootstrap localhost:9092 --protocol PLAINTEXT
Starting Kafka Producer. Use Ctrl-C or Ctrl-D to exit.

$ confluent kafka topic consume test_topic --bootstrap localhost:9092 --protocol PLAINTEXT --from-beginning
Starting Kafka Consumer. Use Ctrl-C to exit.
^CStopping Consumer.

Thanks for your feedback. Unfortunately, I’m not logged in (see 4. point).

But since the --url and --no-authentication options seem to work for you: May I ask which version of the confluent cli you are using and on which OS? Maybe that is the culprit … ?

% confluent version
confluent - Confluent CLI

Version:     v3.55.0
Git Ref:     76551caba
Build Date:  2024-03-29T21:39:33Z
Go Version:  go1.21.7 X:boringcrypto (darwin/amd64)
Development: false

Ok, after trying w/ various (also old versions) I found out that the existing config in ~/.confluent/config.json seemed to confuse the cli tool. I dropped the whole folder and now it works. The error message Error: unknown flag: --url is IMO a bit misleading - I understood that the tool doesn’t support this parameter at all (which is not the case).

Anyway, thanks alot! :grinning:

Good find. I agree that’s a misleading error. I’ll raise this with the CLI team at Confluent to see if we can avoid this. Do you happen to have the contents of the ~/.confluent/config.json file available, or recall any of its contents? :crossed_fingers:

Thanks! Unfortunately I deleted the directory (a pitty, because usually I first just move things away - but in this case I didn’t expect to loose anything important since it is automatically recreated). Sorry! :pensive: