Confluent Enterprise Quick Start (Docker)

This quick start shows you how to get up and running with Confluent Enterprise and its main components using Docker containers. This quick start will show you the basic and most powerful capabilities of Confluent Enterprise, including using Control Center for topic management and stream processing by using KSQL. In this quick start you will create Kafka topics and streaming queries on these topics by using KSQL. You will then go to Control Center to monitor and analyze the streaming queries!

You can also run an automated version of this quick start designed for Confluent Platform local installs.

  • Docker
    • Docker version 1.11 or later is installed and running.
    • Docker Compose is installed. It is installed by default with Docker for Mac and Windows.
    • Docker memory resource is allocated minimally at 8 GB.
  • Git

Step 1: Download and Start Confluent Platform Using Docker

  1. Clone the Confluent Platform Docker Images GitHub Repository and checkout the 5.0.0-post branch.

    git clone
    git checkout 5.0.0-post
  2. Navigate to examples directory (/cp-docker-images/examples/cp-all-in-one/).

  3. Start Confluent Platform in detached mode (-d).

    docker-compose up -d

    This starts the Confluent Platform with separate containers for all Confluent Platform components. Your output should resemble the following:

    Creating network "cp-all-in-one_default" with the default driver
    Creating zookeeper ... done
    Creating broker    ... done
    Creating schema-registry ... done
    Creating rest-proxy      ... done
    Creating connect         ... done
    Creating ksql-datagen    ... done
    Creating ksql-server     ... done
    Creating control-center  ... done
    Creating ksql-cli        ... done
  4. Optional: Run this command to verify that the services are up and running.

    docker-compose ps

    You should see the following:

         Name                    Command               State                Ports
    broker            /etc/confluent/docker/run        Up>29092/tcp,
    connect           /etc/confluent/docker/run        Up>8083/tcp,
    control-center    /etc/confluent/docker/run        Up>9021/tcp
    ksql-cli          ksql http://localhost:8088       Up
    ksql-datagen      bash -c echo Waiting for K ...   Up
    ksql-server       /etc/confluent/docker/run        Up>8088/tcp
    rest-proxy        /etc/confluent/docker/run        Up>8082/tcp
    schema-registry   /etc/confluent/docker/run        Up>8081/tcp
    zookeeper         /etc/confluent/docker/run        Up>2181/tcp,
                                                               2888/tcp, 3888/tcp

    If the state is not Up, rerun the docker-compose up -d command.

Step 2: Create Kafka Topics

In this step you create Kafka topics by using the Confluent Control Center. Confluent Control Center provides the functionality for building and monitoring production data pipelines and streaming applications.

  1. Navigate to the Control Center web interface at http://localhost:9021/.

  2. Select Management -> Topics and click Create on the upper-right corner.

  3. Create a topic named pageviews and click Create with defaults.

  4. Create a topic named users and click Create with defaults.


Step 3: Create Sample Data

In this step you create sample data for the Kafka topics pageviews and users by using the ksql-datagen.


The datagen runs as a long-running process in your terminal. Run each datagen step in a separate terminal.

  1. Produce Kafka data to the pageviews topic using the data generator. The following example continuously generates data with a value in DELIMITED format.

    docker-compose exec ksql-datagen ksql-datagen quickstart=pageviews format=delimited topic=pageviews maxInterval=100 \
    propertiesFile=/etc/ksql/ bootstrap-server=broker:9092
  2. Produce Kafka data to the users topic using the data generator. The following example continuously generates data with a value in JSON format.

    docker-compose exec ksql-datagen ksql-datagen quickstart=users format=json topic=users maxInterval=1000 \
    propertiesFile=/etc/ksql/ bootstrap-server=broker:9092

Step 4: Create and Write to a Stream and Table using KSQL

In this step, KSQL queries are run on the pageviews and users topics that were created in the previous step. The KSQL commands are run using the KSQL tab in Control Center.


You can also run these commands using the KSQL CLI from your Docker container with this command: docker-compose exec ksql-cli ksql http://ksql-server:8088.

Create Streams and Tables

In this step, KSQL is used to create streams and tables for the pageviews and users topics.

  1. From the Control Center interface, click Management -> KSQL.

  2. Click the STREAMS tab and Create a stream and select the pageviews topic.

  3. Choose your stream options and click Save STREAM & query.

    • In the How are your message values encoded? field, select DELIMITED.
    • In the Field(s) you’d like to include in your STREAM field, add additional fields for:
      • viewtime with type BIGINT
      • userid with type VARCHAR
      • pageid with type VARCHAR
  4. Click the TABLES tab and Create a table and then select the users topic.

  5. Choose your table options and click Save TABLE & query.

    • In the How are your message values encoded? field, select JSON.
    • In the Select a key field, select userid.
    • In the Field(s) you’d like to include in your TABLE field, add additional fields for:
      • registertime with type BIGINT
      • gender with type VARCHAR
      • regionid with type VARCHAR
      • userid with type VARCHAR
      • interests with type ARRAY<VARCHAR>
      • contact_info with type MAP<VARCHAR, VARCHAR>

Write Queries

These examples write queries using the KSQL tab in Control Center.

  1. Click KSQL > QUERY EDITOR and Add the custom query property earliest for the auto.offset.reset parameter. This instructs KSQL queries to read all available topic data from the beginning. This configuration is used for each subsequent query. For more information, see the KSQL Configuration Parameter Reference.

  2. Run the following queries.

    1. Create a query that returns data from a stream with the results limited to three rows.

      SELECT pageid FROM pageviews LIMIT 3;
    2. Create a persistent query that filters for female users. The results from this query are written to the Kafka PAGEVIEWS_FEMALE topic. This query enriches the pageviews STREAM by doing a LEFT JOIN with the users TABLE on the user ID, where a condition (gender = 'FEMALE') is met.

      CREATE STREAM pageviews_female AS SELECT users.userid AS userid, pageid, regionid, gender FROM pageviews LEFT JOIN users ON pageviews.userid = users.userid WHERE gender = 'FEMALE';
    3. Create a persistent query where a condition (regionid) is met, using LIKE. Results from this query are written to a Kafka topic named pageviews_enriched_r8_r9.

      CREATE STREAM pageviews_female_like_89 WITH (kafka_topic='pageviews_enriched_r8_r9', value_format='DELIMITED') AS SELECT * FROM pageviews_female WHERE regionid LIKE '%_8' OR regionid LIKE '%_9';
    4. Create a persistent query that counts the pageviews for each region and gender combination in a tumbling window of 30 seconds when the count is greater than 1. Because the procedure is grouping and counting, the result is now a table, rather than a stream. Results from this query are written to a Kafka topic called PAGEVIEWS_REGIONS.

      CREATE TABLE pageviews_regions AS SELECT gender, regionid , COUNT(*) AS numusers FROM pageviews_female WINDOW TUMBLING (size 30 second) GROUP BY gender, regionid HAVING COUNT(*) > 1;

    Click PERSISTENT QUERIES and you should see the following:


Step 5: View Your Stream in Control Center

From the Control Center interface you can view all of your streaming KSQL queries.

Navigate to the Control Center web interface Monitoring -> Data streams tab at http://localhost:9021/monitoring/streams. The monitoring page shows the total number of messages produced and consumed on the cluster. You can scroll down to see more details on the consumer groups for your queries.


Depending on your machine, these charts may take a few minutes to populate and you might need to refresh your browser.


Now that your streams are running you can monitor them.

  • View the consumers that have been created by KSQL

    Click the CONSUMER GROUPS tab and then the View Details button for the _confluent-ksql-default_query_CSAS_PAGEVIEWS_FEMALE_LIKE_89 consumer group.


    This graph shows the messages being consumed by the stream query.


Next Steps

Learn more about the components shown in this quick start: