Docker Overview
Virtualization technology has evolved significantly since the inception of operating systems. In the context of cloud-native computing, containers play a critical role in modern deployment architectures.
Docker is an open-source project that provides an additional abstraction layer on Linux operating systems, enabling users to deploy applications in isolated runtime environments with automated management capabilities.
It is important to distinguish between Docker and containers generally. Docker represents just one container implementation among several alternatives, including Kata containers and Rocket containers.
Build Environment Configuration
Prepare a virtual machine running a compatible Linux distribution such as Ubuntu or openEuler.
Environment Setup
To set up the development enviroment, follow these steps on the Ubuntu virtual machine to obtain OpenAtom OpenHarmony source code and configure the Docker compilation environment.
1. Install the gitee repo tool
mkdir ~/bin
curl https://gitee.com/oschina/repo/raw/fork_flow/repo-py3 -o ~/bin/repo
chmod a+x ~/bin/repo
pip3 install -i https://repo.huaweicloud.com/repository/pypi/simple requests
2. Fetch OpenHarmony source code
Create a source directory on the virtual machine:
mkdir /home/openharmony
cd /home/openharmony
Initialize and sync the OpenHarmony v3.2 release repository:
repo init -u git@gitee.com:openharmony/manifest.git -b OpenHarmony-3.2-Release --no-repo-verify
repo sync -c
repo forall -c 'git lfs pull'
After completion, the complete source tree required for OpenHarmony compilation will be available locally.
3. Configure Docker build environment
The standalone Docker compilation environment supports building lite, small, and standard system configurations.
a) Pull the OpenHarmony Docker compilation image:
docker pull swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
The Docker image is substantial; allow sufficient time for the download to complete.
b) Navigate to the source root directory and launch the Docker container:
cd /home/openharmony
docker run --name ohos_build -it -v $(pwd):/home/openharmony swr.cn-south-1.myhuaweicloud.com/openharmony-docker/openharmony-docker:1.0.0
The -v parameter mounts the host directory X to container directory Y, making the local source tree accessible within the container's /home/openharmony path.
c) Install compilation dependencies:
Inside the container shell, change to the source directory and execute the dependency installation script:
cd /home/openharmony
./build/prebuilts_download.sh
Multiple dependencies are fetched during this step; the process may take considerable time.
With the OpenHarmony Docker compilation environment prepared, kernel feature modifications are required before building to ensure Docker runtime compatibility on OpenHarmony systems.
Kernel Configuration Adjustments
Validating whether the default kernel configuration supports Docker execution can be accomplished using validation tools available in the open-source community. The following section details the necessary kernel configuration changes.
1. Modify OpenHarmony kernel configuration to enable Docker dependencies
The configuration file requiring updates is located at:
kernel/linux/config/linux-5.10/arch/arm64/configs/rk3568_standard_defconfig
Key kernel features for Docker support include namespace isolatoin, control groups, networking capabilities, and overlay filesystem support. Append the following configuration directives to the end of the file:
# add for Docker
CONFIG_POSIX_MQUEUE=y
CONFIG_SCHED_WALT=y
CONFIG_CGROUP=y
CONFIG_CGROUP_SCHED=y
CONFIG_CGROUP_CPU=y
CONFIG_CGROUP_DEVICE=y
CONFIG_CGROUP_FREEZER=y
CONFIG_CGROUP_PIDS=y
CONFIG_CGROUP_MEMCG=y
CONFIG_NET_NS=y
CONFIG_IPC_NS=y
CONFIG_UTS_NS=y
CONFIG_PID_NS=y
CONFIG_OVERLAY_FS=y
CONFIG_AUFS_FS=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_THIN_PROVISIONING=y
CONFIG_VETH=y
CONFIG_BRIDGE=y
CONFIG_NAMESPACES=y
These kernel options enable the fundamental container runtime capabilities required by Docker. After applying these changes, recompile the kernel to activate the new configuration features.