Compiling with Docker (Recommended)
This guide is about how to compile Doris using the official compilation image provided. As this image is maintained by the Apache Doris team and is regularly updated with the necessary dependencies, it is the recommended way of compilation for users.
Install Dockerβ
In CentOS, execute the following command:
yum install docker
Or refer to the official Docker installation doc.
Download build imageβ
For different versions of Doris, you need to download different build images. The "apache/doris:build-env-ldb-toolchain-latest" image is used for compiling the latest master code, and it is regularly updated to align with the master.
Image Version | Doris Version |
---|---|
apache/doris:build-env-for-2.0 | 2.0.x |
apache/doris:build-env-for-2.0-no-avx2 | 2.0.x |
apache/doris:build-env-ldb-toolchain-latest | master |
apache/doris:build-env-ldb-toolchain-no-avx2-latest | master |
Take Doris 2.0 as an example, download and check the correponding Docker image.
# Choose docker.io/apache/doris:build-env-for-2.0
$ docker pull apache/doris:build-env-for-2.0
# Check if it is downloaded
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
apache/doris build-env-for-2.0 f29cf1979dba 3 days ago 3.3GB
Note:
- Download the right image version for the Doris version that you're working with. The image version number is aligned with the Doris version number. For example, you should use "apache/doris:build-env-for-2.0" to compile Doris 2.0.
apache/doris:build-env-ldb-toolchain-latest
is used for compiling the latest master code and is updated along with the master. You can check the update time in thedocker/README.md
file.- Images with "no-avx2" in their names contain third-party libraries that can run on CPUs that do not support AVX2 instructions. Using these images, you can compile Doris with the "USE_AVX2=0".
- For information about changes in the compilation image, please see ChangeLog.
Compile Dorisβ
1. Download Doris source codeβ
Log in to the host machine and obtain the latest code from the Doris 2.0 branch via git clone.
$ git clone -b branch-2.0 https://github.com/apache/doris.git
After downloading, assume that the source code path is in the "doris-branch-2.0" directory.
2. Run build imageβ
# Pre-build a Maven .m2 directory on the host machine to reuse the downloaded Java libraries in Docker.
mkdir ~/.m2
# Run the build image
docker run -it --network=host --name mydocker -v ~/.m2:/root/.m2 -v ~/doris-branch-2.0:/root/doris-branch-2.0/ apache/doris:build-env-for-2.0
# After successful execution, it should be in the Docker.
Note:
- It is recommended to run the image by mounting the local Doris source code directory. This way, the compiled binary files will be stored on the host machine and will not be lost when the container exits.
- It is also recommended to mount the
.m2
directory of Maven in the image to a directory on the host machine. This prevents repeated downloads of Maven dependencies each time the image is started for compilation. - When running the image for compilation, if there is a need to download additional files, it is suggested to use the host mode. The host mode does not require the use of
-p
for port mapping and allows sharing the network IP and ports with the host machine. - Below are explanations for some of the parameters used in the
docker run
command:
Parameter | Description |
---|---|
-v | Mount a storage volume to a specific directory within a container. |
--name | Specify a name for the container to use the assigned name in future container management. |
--network | Container network settings: "bridge" uses the Docker daemon's specified bridge network, "host" allows the container to use the host's network, "container:NAME_or_ID" uses the network of another container by sharing IP and port resources, "none" enables the container to use its own network (similar to --net=bridge) without any additional configuration. |
3. Execute the buildβ
# By default, it builds the AVX2 version.
$ sh build.sh
# If you need the no AVX2 version, add USE_AVX2=0.
$ USE_AVX2=0 sh build.sh
# To compile a debug version of BE, add BUILD_TYPE=Debug.
$ BUILD_TYPE=Debug sh build.sh
To check if the machine supports AVX2:
$ cat /proc/cpuinfo | grep avx2
After compilation, the output file is in the output/
directory.
Build your own development environment imageβ
You can create a Doris development environment image by referring to the docker/README.md
file.