DEV Community

Lemon
Lemon

Posted on

How to use docker to compile Apache Doris

There are more and more new features developed based on the doris master branch:https://github.com/apache/doris however, these new features have not been released in time to follow the version release,But for users, these new features are an urgent need to use.

As a developer in the Apache Doris community,I offer two possible suggestions,1: Ask questions in the slack community or private message me(email: liqianfeng@selectdb.com), the community will directly provide compiled binary packages for user testing. 2: Pull the code and compile it yourself. So this article teaches you how to use docker to compile doris.

Step 1 :

Pull the doris code from the ~ directory of your server

[lqf@host ~]$ cd ~
[lqf@host ~]$ git clone https://github.com/apache/doris.git
Enter fullscreen mode Exit fullscreen mode

Notice:Other directories can also be used here,

but the corresponding doris directory should be modified when starting docker

Step 2 :Download the Docker image

[lqf@host ~]$ docker pull apache/doris:build-env-ldb-toolchain-latest
Enter fullscreen mode Exit fullscreen mode

Step 3:Set Maven warehouse mount and output file directory mount and start docker

docker run -it -v ${your_home_directory}/.m2:/root/.m2 -v ${your_home_directory}/doris:/root/doris apache/doris:build-env-ldb-toolchain-latest
# For example
#my home directory
[lqf@host ~]$ pwd
/mnt/disk1/lqf
[lqf@host ~]$ docker run -it -v /mnt/disk1/lqf/.m2:/root/.m2 -v /mnt/disk1/lqf/doris:/root/doris apache/doris:build-env-ldb-toolchain-latest
Enter fullscreen mode Exit fullscreen mode

Step 4:

After the step 3 is successfully executed, you should have entered docker

Now you need to pay attention,You need to confirm whether your docker has network by ping IP :

[root@host ~]# ping www.google.com
PING www.google.com (172.217.27.36) 56(84) bytes of data.
64 bytes from sin11s03-in-f36.1e100.net (172.217.27.36): icmp_seq=1 ttl=117 time=1.42 ms
64 bytes from sin11s03-in-f36.1e100.net (172.217.27.36): icmp_seq=2 ttl=117 time=1.40 ms
^C
--- www.google.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 1.404/1.412/1.420/0.008 ms
、
[root@host ~]# ping registry.npmjs.org
PING registry.npmjs.org (104.16.22.35) 56(84) bytes of data.
64 bytes from 104.16.22.35 (104.16.22.35): icmp_seq=1 ttl=56 time=1.67 ms
64 bytes from 104.16.22.35 (104.16.22.35): icmp_seq=2 ttl=56 time=1.53 ms
Enter fullscreen mode Exit fullscreen mode

if there is not:

[root@docker ~]# ping www.google.com
ping: www.google.com: Name or service not known
[root@docker ~]# ping registry.npmjs.org
ping: registry.npmjs.org: Name or service not known
Enter fullscreen mode Exit fullscreen mode

First you need to have a network on the host machine,And start docker in host mode.

# Add parameters --network host
# For example
[root@host ~]$ docker run  -it --network host -v /mnt/disk1/lqf/.m2:/root/.m2 -v /mnt/disk1/lqf/doris:/root/doris apache/doris:build-env-ldb-toolchain-latest
Enter fullscreen mode Exit fullscreen mode

then switch JDK version(Choose one)

# switch to JDK 8:
[root@docker ~]$ alternatives --set java java-1.8.0-openjdk.x86_64
[root@docker ~]$ alternatives --set javac java-1.8.0-openjdk.x86_64
[root@docker ~]$ export JAVA_HOME=/usr/lib/jvm/java-1.8.0

# switch to JDK 11:
[root@docker ~]$ alternatives --set java java-11-openjdk.x86_64
[root@docker ~]$ alternatives --set javac java-11-openjdk.x86_64
[root@docker ~]$ export JAVA_HOME=/usr/lib/jvm/java-11
Enter fullscreen mode Exit fullscreen mode

Step 5:start compiling
There will be a doris directory in docker

[root@docker ~]# cd doris/
[root@docker ~]# sh build.sh 
Enter fullscreen mode Exit fullscreen mode

During the compilation process, errors may be reported due to insufficient memory and other reasons.At this time, you only need to execute the command again “sh build.sh”

After the compilation is successful :

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  13:16 min
[INFO] Finished at: 2023-02-23T13:23:32Z
[INFO] ------------------------------------------------------------------------
Install auditloader...
Build Auditloader Finished
***************************************
Successfully build Doris
***************************************
Enter fullscreen mode Exit fullscreen mode

Now you need to enter the doris directory of your host machine,There will be an output directory here.

[lqf@host ~]$ cd doris/
[lqf@host doris]$ cd output/
[lqf@host output]$ ll
total 20
drwxr-xr-x  6 root root 4096 Feb 23 21:10 apache_hdfs_broker
drwxr-xr-x  2 root root 4096 Feb 23 21:23 audit_loader
drwxr-xr-x 10 root root 4096 Feb 23 21:01 be
drwxr-xr-x 10 root root 4096 Feb 23 21:01 fe
drwxr-xr-x  4 root root 4096 Feb 23 21:01 udf
Enter fullscreen mode Exit fullscreen mode

Now congratulations on your successful compilation, you can happily use doris.

Finally, if you get unresolvable errors during compilation,You need to ask your questions in the slack community, the slack entry can be found on the Apache Doris official website:https://doris.apache.org/ , Or you can also private message me directly: liqianfeng@selectdb.com

Top comments (0)