Skip to main content
Last updated on

Compiling Apache Doris with Docker Images

This document describes how to compile Doris source code using the official Apache Doris build image. The image is maintained by the community and updated promptly with dependencies, removing the need to manually install the toolchain and third-party libraries. It is the most recommended compilation method.

tip

The Docker image method does not yet support compilation and deployment in storage-compute separation mode.

Target Audience, Pros, and Cons​

DimensionDescription
Target audienceDevelopers who want to set up a build environment quickly without manually configuring dependencies
ProsThe image comes preinstalled with thirdparty, toolchain, and JDK, ready to use out of the box
ConsRequires a working Docker environment on the local machine; the image is relatively large (about 3.3 GB)

If Docker is not available on the machine, use LDB Toolchain compilation instead.

1. Install Docker​

On CentOS, install directly through the package manager:

yum install docker

For other distributions, refer to the official Docker installation guide.

2. Choose and Download the Build Image​

Different Doris versions correspond to different build images. apache/doris:build-env-ldb-toolchain-latest is used to compile master branch code and is updated continuously along with the trunk.

Image TagApplicable Doris versionNotes
apache/doris:build-env-for-2.02.0.xSupports the AVX2 instruction set
apache/doris:build-env-for-2.0-no-avx22.0.xCompatible with CPUs that do not support AVX2
apache/doris:build-env-for-2.12.1.xSupports the AVX2 instruction set
apache/doris:build-env-for-2.1-no-avx22.1.xCompatible with CPUs that do not support AVX2
apache/doris:build-env-for-3.03.0.xSupports the AVX2 instruction set
apache/doris:build-env-for-3.0-no-avx23.0.xCompatible with CPUs that do not support AVX2
apache/doris:build-env-for-3.13.1.xSupports the AVX2 instruction set
apache/doris:build-env-for-3.1-no-avx23.1.xCompatible with CPUs that do not support AVX2
apache/doris:build-env-ldb-toolchain-latestmasterTracks the trunk
apache/doris:build-env-ldb-toolchain-no-avx2-latestmasterCompatible with CPUs that do not support AVX2

Run these commands on the host. This example builds master; for a release branch, change both the branch and image using the table above. Run the remaining host commands in the same shell to retain these variables. For ARM64 and JDK variations, see Notes on Image Selection.

DORIS_BRANCH=master
DORIS_BUILD_IMAGE=apache/doris:build-env-ldb-toolchain-latest
DORIS_SOURCE_DIR="$PWD/doris"

docker pull "$DORIS_BUILD_IMAGE"

3. Compile Doris​

3.1 Download the Doris Source Code​

On the host, clone the selected branch into the directory configured above:

git clone --branch "$DORIS_BRANCH" https://github.com/apache/doris.git "$DORIS_SOURCE_DIR"

3.2 Start the Build Container​

mkdir -p "$HOME/.m2"

docker run -it --network=host \
--name doris-build \
-v "$HOME/.m2:/root/.m2" \
-v "$DORIS_SOURCE_DIR:/root/doris" \
--workdir /root/doris \
"$DORIS_BUILD_IMAGE"

The command opens Bash inside the container, with the mounted source directory /root/doris as the working directory.

Explanation of the key docker run parameters:

ParameterPurpose
-vMounts a host directory into the container, used to persist source code and dependencies
--nameSpecifies the container name for easier management later
--workdirStarts the shell in the mounted source directory
--networkSets the container network mode. host shares the network stack with the host and requires no port mapping

Recommendations:

  • Always mount the Doris source directory so that the build artifacts remain on the host and are not lost when the container exits.
  • Mount the .m2 directory to avoid re-downloading Maven dependencies every time the container starts.
  • Downloading third-party libraries inside the container requires internet access. The --network=host mode is recommended.

3.3 Run the Build​

Inside the container, run the default build:

bash build.sh

When the build finishes, the artifacts are located under output/ in the source directory.

tip

How do you check whether the machine supports the AVX2 instruction set?

cat /proc/cpuinfo | grep avx2

Non-empty output means AVX2 is supported.

Other Build Options​

Choose one of these commands instead of the default build when needed:

# For CPUs without AVX2
USE_AVX2=0 bash build.sh

# Build the Debug version of BE
BUILD_TYPE=Debug bash build.sh

Notes on Image Selection​

  • Image tags map one-to-one to Doris versions. Select the image that matches the target branch and avoid cross-version compilation.
  • The third-party libraries in no-avx2 images can run on CPUs that do not support AVX2. They must be compiled together with the USE_AVX2=0 option.
  • For the image change history, refer to the thirdparty CHANGELOG.
  • The latest apache/doris:build-env-ldb-toolchain-latest (currently only supports the x86_64 architecture) includes both JDK 8 and JDK 17. Use JDK 8 for versions 2.1 and earlier, and use JDK 17 for versions 3.0 and later or the master branch.
  • When compiling with Docker on the ARM64 architecture, first download an ARM64-compatible Linux base image (such as apache/doris:base-latest, which corresponds to Ubuntu 22.04.5 LTS), and then refer to the Linux direct compilation and ARM platform compilation documents to install dependencies and compile.

Inside the container, switch the JDK through environment variables:

# Switch to JDK 8
export JAVA_HOME=/usr/lib/jvm/java-1.8.0
export PATH=$JAVA_HOME/bin/:$PATH

# Switch to JDK 17
export JAVA_HOME=/usr/lib/jvm/jdk-17.0.2/
export PATH=$JAVA_HOME/bin/:$PATH

4. Build Your Own Development Image​

To customize the base image (for example, to switch to a different base distribution or add debugging tools), refer to docker/README.md in the source code.

FAQ​

Q1: What happens if the image version does not match the Doris version?​

The thirdparty libraries and toolchain in the image are tightly coupled with the Doris source code. Cross-version combinations are very likely to throw linker errors such as undefined reference or incompatible library during compilation. Select strictly according to the table.

Q2: The build reports AVX2 not supported?​

The CPU on the host or the target runtime machine does not support the AVX2 instruction set. Switch to an image with the no-avx2 suffix and set USE_AVX2=0 at build time.

Q3: docker pull is too slow to pull the image?​

Configure a Docker image mirror accelerator, or use the full path docker.io/apache/doris:....

Q4: Java library downloads fail inside the container?​

Verify that the container is started with --network=host, and that the ~/.m2 directory is mounted into the container, so that a proxy or network isolation does not make the Maven central repository unreachable.

Q5: Git reports detected dubious ownership in repository?​

A mounted source directory may be owned by a different host user. After confirming that you trust the source repository, add an exception for its mounted path inside the container:

git config --global --add safe.directory /root/doris

If you changed the container mount path, replace /root/doris accordingly.