Tutorial: Run with Docker

    Before beginning the quickstart, it is helpful to read the general Druid overview and the , as the tutorials will refer to concepts discussed on those pages. Additionally, familiarity with Docker is recommended.

    This tutorial assumes you will download the required files from GitHub. The files are also available in a Druid installation and in the Druid sources.

    The default launches eight containers: Zookeeper, PostgreSQL, and six Druid containers. Each Druid service is configured to use up to 7 GB of memory (6 GB direct memory and 1 GB heap). However, the Quickstart will not use all the available memory.

    Docker needs at least 6 GiB of memory available for the Druid cluster. For Docker Desktop on Mac OS, adjust the memory settings in the Docker Desktop preferences. If you experience a crash with a 137 error code you likely don’t have enough memory allocated to Docker.

    Create a directory to hold the Druid Docker files.

    The Druid source code contains an example docker-compose.yml which pulls an image from Docker Hub and is suited to be used as an example environment and to experiment with Docker based Druid configuration and deployments. this file to the directory created above.

    The example docker-compose.yml will create a container for each Druid service, as well as ZooKeeper and a PostgreSQL container as the metadata store.

    It will also create a named volume druid_shared as deep storage to keep and share segments and task logs among Druid services. The volume is mounted as opt/shared in the container.

    The Druid docker-compose.yml example uses an environment file to specify the complete Druid configuration, including the environment variables described in . This file is named environment by default, and must be in the same directory as the docker-compose.yml file. Download the example environment file to the directory created above. The options in this file work well for trying Druid and for using the tutorial.

    Configuration of the Druid Docker container is done via environment variables set within the container. Docker Compose passes the values from the environment file into the container. The variables may additionally specify paths to the standard Druid configuration files which must be available within the container.

    The default values are fine for the Quickstart. Production systems will want to modify the defaults.

    Basic configuration:

    • DRUID_MAXDIRECTMEMORYSIZE — set Java max direct memory size. Default is 6 GiB.
    • — set Java Xmx, the maximum heap size. Default is 1 GB.

    Production configuration:

    • DRUID_CONFIG_COMMON — full path to a file for Druid common properties
    • DRUID_CONFIG_${service} — full path to a file for Druid service properties

    Logging configuration:

    • DRUID_LOG4J — set the entire verbatim. (Example)
    • DRUID_LOG_LEVEL — override the default

    Advanced memory configuration:

    • DRUID_XMS — set Java Xms, the initial heap size. Default is 1 GB.
    • DRUID_MAXNEWSIZE — set
    • DRUID_NEWSIZE — set Java new size

    In addition to the special environment variables, the script which launches Druid in the container will use any environment variable starting with the druid_ prefix as command-line configuration. For example, an environment variable

    druid_metadata_storage_type=postgresql

    is translated into the following option in the Java launch command for the Druid process in the container:

    Note that Druid uses port 8888 for the console. This port is also used by Jupyter and other tools. To avoid conflicts, you can change the port in the section of the docker-compose.yml file. For example, to expose the console on port 9999 of the host:

    cd into the directory that contains the configuration files. This is the directory you created above, or the distribution/docker/ in your Druid installation directory if you installed Druid locally.

    Run docker-compose up to launch the cluster with a shell attached, or docker-compose up -d to run the cluster in the background.

    Once the cluster has started, you can navigate to the at http://localhost:8888. The serves the UI.

    It takes a few seconds for all the Druid processes to fully start up. If you open the console immediately after starting the services, you may see some errors that you can safely ignore.

    From here you can follow along with the . For production use, refine your docker-compose.yml file to add any additional external service dependencies as necessary.

    You can explore the Druid containers using Docker to start a shell:

    1. docker exec -ti <id> sh

    Where <id> is the container id found with docker ps. Druid is installed in /opt/druid. The script which consumes the environment variables mentioned above, and which launches Druid, is located at /druid.sh.