0

Objective: An image which has both Python, and Kafka tools available.

I started with Docker multistage builds but soon realized that I got the concept wrong:

# syntax=docker/dockerfile:1

FROM confluentinc/cp-kafka:latest
WORKDIR /home/appuser
RUN ["kafka-topics","--version"]

FROM python:alpine
CMD ["python"]

This builds a small image with just Python alpine.

So how do write a Dockerfile that will use two base images to build a new one?

Kaliyug Antagonist
  • 3,512
  • 9
  • 51
  • 103
  • You can't. An image cannot be based on two other images. --- This sounds like an [XY problem (`meta.stackexchange.com`)](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). Why do you want to base one image on two other images? – Turing85 May 19 '23 at 10:56
  • 1
    For what you're describing, a more typical setup would be to use Docker Compose to run a Kafka broker in one container, and your Kafka client application (`FROM python` only) in a second. (And maybe you need a third container with ZooKeeper.) The setup to run them in the same container is much more complex than just running multiple containers. – David Maze May 19 '23 at 11:04

0 Answers0