Member-only story
Introduction
This step-by-step guide shows how to install Apache Kafka within a Ubuntu docker image. The reason why we choose a docker image here is so that we have a clean environment to work with.
Install Docker
To begin with, make sure you have Docker installed properly on your machine:
$ docker --versionDocker version 18.09.2, build 6247962
If you don’t have Docker installed, you download & install it from https://docs.docker.com/.
Ubuntu Container
Ubuntu docker image is available at the Docker Hub https://hub.docker.com/_/ubuntu. We’ll use the current latest version for this tutorial, which is 18.04. The following command docker run -it
allows us to launch the docker image in the interactive foreground mode.
$ docker run -it ubuntu:18.04 bashUnable to find image 'ubuntu:latest' locally
latest: Pulling from library/ubuntu
898c46f3b1a1: Pull complete
63366dfa0a50: Pull complete
041d4cd74a92: Pull complete
6e1bee0f8701: Pull complete
Digest: sha256:017eef0b616011647b269b5c65826e2e2ebddbe5d1f8c1e56b3599fb14fabec8
Status: Downloaded newer image for ubuntu:18.04
root@744905c2e61c:/#
We’ll do the rest of this tutorial inside this container.
Install Kafka
Kafka was written in Java and Scala. Let’s install Java on the machine.
Update apt-get
:
# apt-get updateGet:1 http://archive.ubuntu.com/ubuntu bionic InRelease [242 kB]
...
Fetched 15.7 MB in 4s (3903 kB/s)
Reading package lists... Done
Install Java:
# apt-get install default-jre...
done.
And check its version to make sure that we’ve installed java successfully.
# java -versionopenjdk version "10.0.2" 2018-07-17
OpenJDK Runtime Environment (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4)
OpenJDK 64-Bit Server VM (build 10.0.2+13-Ubuntu-1ubuntu0.18.04.4, mixed mode)
Install wget
:
# apt install wgetReading package lists... Done
Building dependency tree
...
done.