Confluent Go Client with Docker

Saturday, Feb 29, 2020 | 3 minute read

Ricardo Ferreira

If you are reading this blog post then there is a high chance that you’ve been looking for ways to make Confluent’s Go Client for Apache Kafka work with your Docker images but you’re struggling to. Am I right?

Don’t worry, you’ve came to the right place. After struggling with this myself I decided to share the solution that I’ve found with everybody else so we all can spend more time writing code than just wasting time with dependency plumbing.

Going straight to the point – there are two decisions that you need to make for this to work:

  • Which base image to derive from?
  • How to install Golang into your image?

This may sound obvious but the best way to get a Docker image with Go on it is by using Go’s official Docker image. And if you’re like me, this might have been your first instinct in the process of building an image for your application.

Try to resist to that instinct. It turns out that in order to have Confluent’s Go client you will need to install some extra dependencies – notably Confluent’s implementation of the librdkafka library – and if you derive from the golang base image you won’t be able to. Well… at least not easily.

So as your first step, you need to derive from a base image that will allow the installation of the dependencies that ultimately will in turn allow you to get the right librdkafka implementation. In my case I used this one:

FROM fedora:latest

Then you can now install Confluent’s librdkafka:

RUN rpm --import https://packages.confluent.io/rpm/5.4/archive.key
COPY confluent.repo /etc/yum.repos.d
RUN dnf install librdkafka-devel -y

One of the cool things about this approach is that not only you can now ensure that you’re fetching Confluent’s librdkafka (instead of any outdated implementation) but also you get to decide which specific version to use.

Now remember when I mentioned the decision about how to install Go into your image?

Since we’re not deriving from the golang base image anymore, it is up to you now to get it installed into the image. This is not actually a very hard task since you can use the image’s dependency management system (in Fedora’s case, dnf) for that purpose but the reality is that usually they don’t have the exact version of Go you need.

What worked for me was simply to download the latest bits and set it up by myself:

RUN wget https://dl.google.com/go/go1.14.linux-amd64.tar.gz && tar -xvf go1.14.linux-amd64.tar.gz && rm go1.14.linux-amd64.tar.gz
RUN mv go /usr/local
ENV GOROOT=/usr/local/go
ENV PATH="${GOROOT}/bin:${PATH}"

That is it : now you have both Confluent’s librdkafka and Go in your Docker image. Bring your code into it, build it, and have fun with your new image.

I have published a sample application on GitHub that might help you as well.

© 2018 - 2026 Ricardo Ferreira

Search is powered by Pagefind. Just hit CTRL+K or CMD+K to start searching.

Powered by Hugo with Dream and Devrel themes.

Open Source

I contribute to LangChain4j, an idiomatic open source Java library for building LLM-powered applications on the JVM. Recent work includes adding native vector search embedding stores so developers can build RAG, recommendation engines, and AI memory systems.

I also ported RedisVL to Go, an open source, AI-native client that brings vector search, semantic caching, LLM memory, semantic routing, rerankers, and an MCP server to the Redis ecosystem for Golang developers.

Speaking

I’ve been speaking at conferences since 2008 and doing it full time as part of my work since 2018. Some of the events I’ve spoken at include AWS re:Invent, Microsoft Ignite, Google Cloud Next, KubeCon, Oracle OpenWorld, QCon, Strange Loop, Kafka Summit, Pulsar Summit, JavaOne, DevNexus, JFokus, JNation, and All Things Open.

Recordings of my talks live on my YouTube channel, and the code I write for talks, demos, and tutorials is on my GitHub.

Who am I?

I work at the intersection of distributed systems, AI, and data infrastructure, turning complex technology into things developers can understand, adopt, and build with.

Lately, that means hands-on AI engineering: building vector search, semantic caching, agent memory, and RAG into the data layer; contributing to LangChain4j and RedisVL for Golang; and figuring out how to make AI agents secure enough to ship.

The AI-native work isn’t a pivot. It draws on the same systems-design foundation I’ve built for 20+ years, moving data fast, at scale, close to compute, watching where systems break; now applied to vectors and agents. I have worked on event streaming with Apache Kafka and Flink at AWS and Confluent; observability at Elastic; as well as RDBMS, NoSQL, and Big Data at Oracle. That foundation is exactly what separates AI demos that work on stage from AI systems that survive production.

Social Links