This guide is about how to create a running image of Apache Doris using a Dockerfile. It allows for the quick pulling of an Apache Doris image to create and run a cluster, either with container orchestration tools or for a quick test.

Prerequisites

Overview

Prepare the build machine before creating the Docker image. The platform architecture of this machine determines the platform architecture for which the Docker image will be applicable. For example, if you use an X86_64 machine, you should download the X86_64 Doris binary program, because the resulting image will only run on X86_64 platforms. The same applies to ARM64 platforms.

Hardware

Recommended configuration: 4 cores, 16GB memory.

Software

Docker version: 20.10 or later.

Build image

Preparation

Dockerfile script writing

  • Choose a Docker Hub-certified OpenJDK official image as the base parent image. The recommended base parent image is: openjdk:8u342-jdk (JDK 1.8 version).
  • Use embed scripts for FE startup, multi-FE registration, FE status checks, BE startup, BE registration in FE, and BE status checks.
  • Avoid using the --daemon option to start the application within Docker, as it may cause issues during deployment with orchestration tools like Kubernetes (K8s).

Methods to build

About the Dockerfile script used for compiling the Docker image, there are two ways to load the Apache Doris binary package:

  • Use wget or curl commands to download the package during compilation and then complete the Docker Build process.
  • Pre-download the binary package to the build directory and load it into the Docker Build process using the ADD or COPY command.

The former method produces a Docker image of smaller size, but if the build fails, the download operation may be repeated, leading to longer build times. The latter method is suitable for environments with unstable network conditions. Here, we will provide an example using the second method.

Build FE Image

  1. Environment directory for building the FE image:

The build environment directory is as follows:

  1. └── docker-build // Root directory
  2. └── fe // FE directory
  3. ├── dockerfile // Dockerfile script
  4. └── resource // Resource directory
  5. ├── init_fe.sh // Startup and registration script
  6. └── apache-doris-2.0.3-bin.tar.gz // Binary package
  1. Download binary package

Download the official binary package or the compiled binary package, and replace the apache-doris package in ./docker-build/fe/resource with it.

  1. Write Dockerfile
  1. # Choose a base image
  2. FROM openjdk:8u342-jdk
  3. # Set environment variables
  4. ENV JAVA_HOME="/usr/local/openjdk-8/"
  5. ENV PATH="/opt/apache-doris/fe/bin:$PATH"
  6. # Download the software into the Docker image
  7. ADD ./resource/apache-doris-2.0.3-bin.tar.gz /opt/
  8. RUN apt-get update && \
  9. apt-get install -y default-mysql-client && \
  10. apt-get clean && \
  11. mkdir /opt/apache-doris && \
  12. cd /opt && \
  13. mv apache-doris-2.0.3-bin/fe /opt/apache-doris/
  14. ADD ./resource/init_fe.sh /opt/apache-doris/fe/bin
  15. RUN chmod 755 /opt/apache-doris/fe/bin/init_fe.sh
  16. ENTRYPOINT ["/opt/apache-doris/fe/bin/init_fe.sh"]
  • Rename the file as Dockerfile and save it to the ./docker-build/fe directory.
  • For the FE execution script init_fe.sh, refer to init_fe.sh in the Doris source code library.
  1. Perform build

Note that ${tagName} should be replaced with the tag you need, such as: apache-doris:2.0.3-fe.

  1. cd ./docker-build/fe
  2. docker build . -t ${fe-tagName}

Build BE image

  1. Environment directory for building the BE image:
  1. └── docker-build // Root directory
  2. └── be // BE directory
  3. ├── dockerfile // Dockerfile script
  4. └── resource // Resource directory
  5. ├── init_be.sh // Startup and registration script
  6. └── apache-doris-2.0.3-bin.tar.gz // Binary package
  1. Write Dockerfile
  1. # Choose a base image
  2. FROM openjdk:8u342-jdk
  3. # Set environment variables
  4. ENV JAVA_HOME="/usr/local/openjdk-8/"
  5. ENV PATH="/opt/apache-doris/be/bin:$PATH"
  6. # 下Download the software into the Docker image
  7. ADD ./resource/apache-doris-2.0.3-bin.tar.gz /opt/
  8. RUN apt-get update && \
  9. apt-get install -y default-mysql-client && \
  10. apt-get clean && \
  11. mkdir /opt/apache-doris && \
  12. cd /opt && \
  13. mv apache-doris-2.0.3-bin/be /opt/apache-doris/
  14. ADD ./resource/init_be.sh /opt/apache-doris/be/bin
  15. RUN chmod 755 /opt/apache-doris/be/bin/init_be.sh
  16. ENTRYPOINT ["/opt/apache-doris/be/bin/init_be.sh"]
  • Rename the file as Dockerfile and save it to the ./docker-build/be directory.
  • For the BE execution script init_be.sh, refer to init_be.sh.
  1. Perform build

Note that ${tagName} should be replaced with the tag you need, such as: apache-doris:2.0.3-be.

  1. cd ./docker-build/be
  2. docker build . -t ${be-tagName}

Push the image to DockerHub or a private repository

Log in to DockerHub

  1. docker login

Upon successful login, a “Success” prompt will be displayed. After that, you can push the image.

  1. docker push ${tagName}

Deploy Docker cluster

The following is a brief overview of how to quickly create a complete Doris testing cluster using the docker run or docker-compose up commands.

It is advisable to avoid containerized solutions for Doris deployment in production environments. Instead, when deploying Doris on Kubernetes (K8s), it is recommended to utilize the Doris Operator for deployment.

Prerequisite

Software

SoftwareVersion
Docker20.0 and later
docker-compose20.1 and later

Hardware

ConfigurationHardwareMaximum Running Cluster Size
Minimum2C 4G1FE 1BE
Recommended4C 16G3FE 3BE

Execute the following command in the host machine:

  1. sysctl -w vm.max_map_count=2000000

Docker Compose

The required image varies depending on the platform. The following takes the X86_64 platform as an example.

Network mode

Doris Docker supports two network modes:

  • The HOST mode is suitable for deploying across multiple nodes, with one FE and one BE per node.
  • The subnet bridge mode is suitable for deploying multiple Doris processes on a single node (recommended). If you want to deploy across multiple nodes, additional component deployments are required (not recommended).

For demonstration purposes, this section will only show scripts written for the subnet bridge mode.

Interface description

Since Apache Doris 2.0.3 Docker Image, the interface list for each process image is as follows:

ProcessInterfaceInterface DefinitionInterface Example
FEBEBROKERFE_SERVERS
FEFE_IDFE node ID1
BEBE_ADDRBE node informatioin172.20.80.5:9050
BENODE_ROLEBE node typecomputation

Note that the above interfaces must be specified with relevant information; otherwise, the process will not start.

The FE_SERVERS interface follows the rule: FE_NAME:FE_HOST:FE_EDIT_LOG_PORT[,FE_NAME:FE_HOST:FE_EDIT_LOG_PORT]

The FE_ID interface should be an integer from 1 to 9, where 1 represents the Master node.

The BE_ADDR interface follows the rule: BE_HOST:BE_HEARTBEAT_SERVICE_PORT

The NODE_ROLE interface should be computation or empty. When it is empty or any other value, it indicates a mix node.

The BROKER_ADDR interface follows the rule: BROKER_HOST:BROKER_IPC_PORT

Script template

Docker Run command

1 FE & 1 BE command template

Note that you should replace ${INTERNAL_IP_OF_CURRENT_MACHINE} with the internal IP of your current machine.

  1. docker run -itd \
  2. --name=fe \
  3. --env FE_SERVERS="fe1:${INTERNAL_IP_OF_CURRENT_MACHINE}:9010" \
  4. --env FE_ID=1 \
  5. -p 8030:8030 \
  6. -p 9030:9030 \
  7. -v /data/fe/doris-meta:/opt/apache-doris/fe/doris-meta \
  8. -v /data/fe/log:/opt/apache-doris/fe/log \
  9. --net=host \
  10. apache/doris:2.0.3-fe-x86_64
  11. docker run -itd \
  12. --name=be \
  13. --env FE_SERVERS="fe1:${INTERNAL_IP_OF_CURRENT_MACHINE}:9010" \
  14. --env BE_ADDR="${INTERNAL_IP_OF_CURRENT_MACHINE}:9050" \
  15. -p 8040:8040 \
  16. -v /data/be/storage:/opt/apache-doris/be/storage \
  17. -v /data/be/log:/opt/apache-doris/be/log \
  18. --net=host \
  19. apache/doris:2.0.3-be-x86_64

Download the Docker Run command template for 3 FE & 3 BE from here if needed.

Docker Compose scripte

1 FE & 1 BE template

Note that you should replace ${INTERNAL_IP_OF_CURRENT_MACHINE} with the internal IP of your current machine.

  1. version: "3"
  2. services:
  3. fe:
  4. image: apache/doris:2.0.3-fe-x86_64
  5. hostname: fe
  6. environment:
  7. - FE_SERVERS=fe1:${INTERNAL_IP_OF_CURRENT_MACHINE}:9010
  8. - FE_ID=1
  9. volumes:
  10. - /data/fe/doris-meta/:/opt/apache-doris/fe/doris-meta/
  11. - /data/fe/log/:/opt/apache-doris/fe/log/
  12. network_mode: host
  13. be:
  14. image: apache/doris:2.0.3-be-x86_64
  15. hostname: be
  16. environment:
  17. - FE_SERVERS=fe1:${INTERNAL_IP_OF_CURRENT_MACHINE}:9010
  18. - BE_ADDR=${INTERNAL_IP_OF_CURRENT_MACHINE}:9050
  19. volumes:
  20. - /data/be/storage/:/opt/apache-doris/be/storage/
  21. - /data/be/script/:/docker-entrypoint-initdb.d/
  22. depends_on:
  23. - fe
  24. network_mode: host

Download the Docker Compose command template for 3 FE & 3 BE from here if needed.

Deploy Doris Docker

Choose one of the following deployment methods:

  1. Execute the docker run command to create the cluster.
  2. Save the docker-compose.yaml script and execute the docker-compose up -dcommand in the same directory to create the cluster.