1.環(huán)境和設(shè)備
系統(tǒng)版本: 3.2release(64 位)
OpenHarmony 內(nèi)核版本:5.10
標(biāo)準(zhǔn)系統(tǒng)設(shè)備: DAYU200
Docker:18.03.1 (64 位)
sd 卡一張
2.準(zhǔn)備支持 Docker 容器的 OpenHarmony 內(nèi)核
1.檢測(cè) DAYU200 3568 OpenHarmony3.2release 內(nèi)核對(duì) docker 的支持
下載檢測(cè)腳本 check-config.sh
2.在編譯命令 ./build.sh --product-name rk3568 --ccache --target-cpu arm64 編譯 arm64 位系統(tǒng)情況下
進(jìn)入 out/kernel/src_tmp/linux-5.10 下執(zhí)行 scripts/extract-ikconfig boot_linux.img > /home/.config 生成 boot_linux.img 內(nèi)核鏡像的配置文件,配置文件此時(shí)輸入到了/home/.config
執(zhí)行腳本 ./check-config.sh .config
內(nèi)核對(duì) docker 的支持.png
3.修改源碼內(nèi)核配置 kernel/linux/config/linux-5.10/rk3568/arch/arm64_defconfig
將必選和可選的配置都打開(kāi),修改內(nèi)核配置
# add for Docker CONFIG_POSIX_MQUEUE=y CONFIG_SCHED_WALT=y CONFIG_PSI=y CONFIG_PAGE_COUNTER=y CONFIG_CGROUP_BPF=y CONFIG_MEMCG_KMEM=y CONFIG_MEMCG_SWAP_ENABLED=y CONFIG_BLK_CGROUP=y CONFIG_BLK_DEV_THROTTLING=y CONFIG_RT_GROUP_SCHED=y CONFIG_CGROUP_PIDS=y CONFIG_CGROUP_HUGETLB=y CONFIG_CGROUP_PERF=y CONFIG_NET_CLS_CGROUP=y CONFIG_BPF_SYSCALL=y CONFIG_BINFMT_MISC=y CONFIG_TLS=y CONFIG_IP_MULTIPLE_TABLES=y CONFIG_IP_MROUTE_MULTIPLE_TABLES=y CONFIG_INET_ESP=y CONFIG_IPV6_MIP6=y CONFIG_IPV6_MULTIPLE_TABLES=y CONFIG_IPV6_MROUTE=y CONFIG_IPV6_MROUTE_MULTIPLE_TABLES=y CONFIG_NF_CONNTRACK=y CONFIG_NETFILTER_XT_MARK=y CONFIG_NETFILTER_XT_SET=y CONFIG_NETFILTER_XT_TARGET_CHECKSUM=y CONFIG_NETFILTER_XT_MATCH_ADDRTYPE=y CONFIG_NETFILTER_XT_MATCH_CONNTRACK=y CONFIG_NETFILTER_XT_MATCH_IPVS=y CONFIG_NETFILTER_XT_MATCH_CGROUP=y CONFIG_IP_SET=y CONFIG_IP_SET_HASH_IP=y CONFIG_IP_SET_HASH_NET=y CONFIG_IP_VS=y CONFIG_IP_VS_NFCT=y CONFIG_IP_VS_PROTO_TCP=y CONFIG_IP_VS_PROTO_UDP=y CONFIG_IP_VS_RR=y CONFIG_IP_VS_WRR=y CONFIG_IP_VS_SH=y CONFIG_IP_NF_MATCH_STATE=y CONFIG_IP_NF_MATCH_LIMIT=y CONFIG_IP_NF_TARGET_LOG=y CONFIG_NF_NAT=y CONFIG_IP_NF_FTP=y CONFIG_IP_NF_TARGET_REDIRECT=y CONFIG_IP_NF_CONNTRACK=y CONFIG_IP_NF_IRC=y CONFIG_IP_NF_NAT=y CONFIG_IP_NF_FILTER=y CONFIG_IP_NF_TARGET_MASQUERADE=y CONFIG_BRIDGE=y CONFIG_BRIDGE_NETFILTER=y CONFIG_CGROUP_NET_PRIO=y CONFIG_STREAM_PARSER=y CONFIG_DRIVERS_HDF_LIGHT=y CONFIG_HYPERHOLD=y CONFIG_HYPERHOLD_DEBUG=y CONFIG_HYPERHOLD_ZSWAPD=y CONFIG_HYPERHOLD_FILE_LRU=y CONFIG_HYPERHOLD_MEMCG=y CONFIG_ZRAM_GROUP=y CONFIG_ZRAM_GROUP_DEBUG=y CONFIG_ZLIST_DEBUG=y CONFIG_ZRAM_GROUP_WRITEBACK=y CONFIG_REGMAP_SPI=y CONFIG_MACVLAN=y CONFIG_VXLAN=y CONFIG_AUFS_FS=y CONFIG_VETH=y CONFIG_DRM_DW_HDMI_I2S_AUDIO=y CONFIG_SND_TIMER=y CONFIG_SND_PCM=y CONFIG_SND_PCM_ELD=y CONFIG_SND_PCM_IEC958=y CONFIG_SND_DMAENGINE_PCM=y CONFIG_SND_HWDEP=y CONFIG_SND_SEQ_DEVICE=y CONFIG_SND_RAWMIDI=y CONFIG_SND_JACK=y CONFIG_SND_JACK_INPUT_DEV=y CONFIG_SND_PCM_TIMER=y CONFIG_SND_HRTIMER=y CONFIG_SND_DYNAMIC_MINORS=y CONFIG_SND_MAX_CARDS=32 CONFIG_SND_PROC_FS=y CONFIG_SND_VERBOSE_PROCFS=y CONFIG_SND_SEQUENCER=y CONFIG_SND_SEQ_DUMMY=y CONFIG_SND_SEQ_HRTIMER_DEFAULT=y CONFIG_SND_SEQ_MIDI_EVENT=y CONFIG_SND_SEQ_MIDI=y CONFIG_SND_DRIVERS=y CONFIG_SND_HDA_PREALLOC_SIZE=64 CONFIG_SND_USB=y CONFIG_SND_USB_AUDIO=y CONFIG_SND_USB_AUDIO_USE_MEDIA_CONTROLLER=y CONFIG_SND_SOC=y CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM=y CONFIG_SND_SOC_ROCKCHIP=y CONFIG_SND_SOC_ROCKCHIP_I2S=y CONFIG_SND_SOC_ROCKCHIP_I2S_TDM=y CONFIG_SND_SOC_ROCKCHIP_PDM=y CONFIG_SND_SOC_ROCKCHIP_SPDIF=y CONFIG_SND_SOC_ROCKCHIP_SPDIFRX=y CONFIG_SND_SOC_ROCKCHIP_MAX98090=y CONFIG_SND_SOC_ROCKCHIP_MULTICODECS=y CONFIG_SND_SOC_ROCKCHIP_RT5645=y CONFIG_SND_SOC_ROCKCHIP_HDMI=y CONFIG_SND_SOC_DUMMY_CODEC=y CONFIG_SND_SOC_HDMI_CODEC=y CONFIG_SND_SOC_ES7202=y CONFIG_SND_SOC_ES7243E=y CONFIG_SND_SOC_ES8311=y CONFIG_SND_SOC_ES8316=y CONFIG_SND_SOC_MAX98090=y CONFIG_SND_SOC_RK3308=y CONFIG_SND_SOC_RK3328=y CONFIG_SND_SOC_RK817=y CONFIG_SND_SOC_RK_CODEC_DIGITAL=y CONFIG_SND_SOC_RL6231=y CONFIG_SND_SOC_RT5616=y CONFIG_SND_SOC_RT5640=y CONFIG_SND_SOC_RT5645=y CONFIG_SND_SOC_RT5651=y CONFIG_SND_SOC_SPDIF=y CONFIG_SND_SOC_TS3A227E=y CONFIG_SND_SIMPLE_CARD_UTILS=y CONFIG_SND_SIMPLE_CARD=y CONFIG_ANDROID_PARANOID_NETWORK=y CONFIG_ACCESS_TOKENID=y CONFIG_F2FS_GRADING_SSR=y CONFIG_OVERLAY_FS=y CONFIG_HUGETLBFS=y CONFIG_HUGETLB_PAGE=y CONFIG_CRYPTO_SEQIV=y CONFIG_BTRFS_FS_POSIX_ACL=y CONFIG_BRIDGE_VLAN_FILTERING=y CONFIG_IPVLAN=y CONFIG_DUMMY=y CONFIG_NF_NAT_FTP=y CONFIG_NF_CONNTRACK_FTP=y CONFIG_NF_NAT_TFTP=y CONFIG_NF_CONNTRACK_TFTP=y CONFIG_BTRFS_FS=y # end ?
4.添加 Docker 運(yùn)行需要的目錄’run’, ‘var’, ‘opt’, ‘usr’。修改 build/ohos/images/build_image.py
'run', 'var', 'opt', 'usr'
5.修改/base/security/selinux/sepolicy/base/system/file_contexts
/run u:object_r:rootfs:s0 /var u:object_r:rootfs:s0 /opt u:object_r:rootfs:s0 /usr u:object_r:rootfs:s0 /lib u:object_r:rootfs:s0
?
修改 file_contexts.png
3.編譯燒錄鏡像
./build.sh --product-name rk3568 --ccache --target-cpu arm64
?
4.安裝 docker 容器引擎組件
1.hdc shell 進(jìn)入開(kāi)發(fā)板終端在/etc/下創(chuàng)建 cgroups.json,cgroups.json 內(nèi)容如下
{ "Cgroups": [ { "UID": "system", "GID": "system", "Mode": "0755", "Controller": "blkio", "Path": "/dev/blkio" }, { "UID": "system", "GID": "system", "Mode": "0755", "Controller": "cpu", "Path": "/dev/cpu" }, { "Mode": "0555", "Path": "/dev/cpuacct", "Controller": "cpuacct" }, { "UID": "system", "GID": "system", "Mode": "0755", "Controller": "cpuset", "Path": "/dev/cpuset" }, { "UID": "system", "GID": "system", "Mode": "0755", "Controller": "memory", "Path": "/dev/memcg" }, { "UID": "system", "GID": "system", "Mode": "0755", "Controller": "schedtune", "Path": "/dev/stune" }, { "GID": "system", "UID": "system", "Mode": "0755", "Controller": "devices", "Path": "/dev/devices" }, { "GID": "system", "UID": "system", "Mode": "0755", "Controller": "freezer", "Path": "/dev/freezer" }, { "GID": "system", "UID": "system", "Mode": "0755", "Controller": "hugetlb", "Path": "/dev/hugetlb" }, { "GID": "system", "UID": "system", "Mode": "0755", "Controller": "net_cls", "Path": "/dev/net_cls" }, { "GID": "system", "UID": "system", "Mode": "0755", "Controller": "net_prio", "Path": "/dev/net_prio" }, { "GID": "system", "UID": "system", "Mode": "0755", "Controller": "perf_event", "Path": "/dev/perf_event" }, { "GID": "system", "UID": "system", "Mode": "0755", "Controller": "pids", "Path": "/dev/pids" }, { "GID": "system", "UID": "system", "Mode": "0755", "Controller": "rdma", "Path": "/dev/rdma" } ], "Cgroups2": { "UID": "root", "GID": "root", "Mode": "0600", "Path": "/dev/cg2_bpf" } } ?
2.安裝 docker 靜態(tài)二進(jìn)制文件
# 下載docker static binaries 18.03.1 https://download.docker.com/linux/static/stable/aarch64/ 若為32位選擇armhf版。 # 解壓并且加入環(huán)境變量 tar zxvf 到/system/bin下 # 給二進(jìn)制文件執(zhí)行權(quán)限 cd /system/bin/docker/ chmod 777 docker chmod 777 docker-containerd-ctr chmod 777 docker-init chmod 777 docker-runc chmod 777 docker-containerd chmod 777 docker-containerd-shim chmod 777 docker-proxy chmod 777 dockerd export PATH=$PATH:/system/bin/ export PATH=$PATH:/system/bin/docker/ ?
5.格式化 sd 卡為 f2fs 文件系統(tǒng)
# 修改root目錄下的權(quán)限使其可以進(jìn)行文件操作 hdc shell mount -o rw,remount -t auto / ?
docker overlay filesystem 推薦 backing filesystem 是未加密的 f2fs。而 RK3568 的 data 分區(qū)是加密的 ext4,可以通過(guò) micro sd card 卡擴(kuò)展 RK3568 的存儲(chǔ)將 sd card 格式化為 f2fs 解決此問(wèn)題。
準(zhǔn)備一個(gè) sd 卡,插入到 DAYU200 板子上
# 查看系統(tǒng)文件系統(tǒng)格式 blkid # 查看系統(tǒng)文件系統(tǒng)和掛載情況 df -h # 確定sd卡的名稱(chēng),將其格式化sd卡為f2fs # 卸載設(shè)備:如果設(shè)備已掛載,使用以下命令卸載設(shè)備:(請(qǐng)確保設(shè)備已成功卸載,不再出現(xiàn)任何輸出。) umount /dev/block/vol-179-97 # 執(zhí)行mkfs.f2fs命令來(lái)創(chuàng)建F2FS文件系統(tǒng): mkfs.f2fs /dev/block/vol-179-97
?
格式化后先不要掛載 sd 卡
6.通過(guò)有線或者無(wú)線連接網(wǎng)絡(luò)
將開(kāi)發(fā)板連接網(wǎng)絡(luò)
# 查看正在運(yùn)行的 ifconfig # 查看所有的網(wǎng)絡(luò)接口 ifconfig -a # 開(kāi)啟ip forward echo "1" > /proc/sys/net/ipv4/ip_forward
?
7.docker 環(huán)境準(zhǔn)備
# 創(chuàng)建docker運(yùn)行需要的目錄 mkdir /system/etc/docker mkdir /data/var mkdir /data/run mkdir /data/tmp mkdir /data/opt mkdir /data/etc mkdir /data/etc/docker mkdir /data/usr mkdir /mnt/f2fs # 掛載剛剛已經(jīng)被f2fs格式化的sd卡設(shè)備,可以用blkid查看到具體的名稱(chēng) mount /dev/block/vol-179-97 /mnt/f2fs/ # 創(chuàng)建一個(gè)1GB大小的tmpfs文件系統(tǒng),并將其掛載到"/sys/fs/cgroup"目錄下,以供cgroup機(jī)制使用。 mount tmpfs /sys/fs/cgroup -t tmpfs -o size=1G mkdir /sys/fs/cgroup/blkio mkdir /sys/fs/cgroup/cpu mkdir /sys/fs/cgroup/cpuacct mkdir /sys/fs/cgroup/cpuset mkdir /sys/fs/cgroup/devices mkdir /sys/fs/cgroup/freezer mkdir /sys/fs/cgroup/hugetlb mkdir /sys/fs/cgroup/memory mkdir /sys/fs/cgroup/net_cls mkdir /sys/fs/cgroup/net_prio mkdir /sys/fs/cgroup/perf_event mkdir /sys/fs/cgroup/pids mkdir /sys/fs/cgroup/rdma mkdir /sys/fs/cgroup/schedtune mkdir /sys/fs/cgroup/systemd mount --bind /data/etc/docker /etc/docker mount --bind /data/var /var mount --bind /data/run /run mount --bind /data/tmp /tmp mount --bind /data/opt /opt mount --bind /data/usr /usr mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd mount -t cgroup -o blkio,nodev,noexec,nosuid cgroup /sys/fs/cgroup/blkio mount -t cgroup -o cpu,nodev,noexec,nosuid cgroup /sys/fs/cgroup/cpu mount -t cgroup -o cpuacct,nodev,noexec,nosuid cgroup /sys/fs/cgroup/cpuacct mount -t cgroup -o cpuset,nodev,noexec,nosuid cgroup /sys/fs/cgroup/cpuset mount -t cgroup -o devices,nodev,noexec,nosuid cgroup /sys/fs/cgroup/devices mount -t cgroup -o freezer,nodev,noexec,nosuid cgroup /sys/fs/cgroup/freezer mount -t cgroup -o hugetlb,nodev,noexec,nosuid cgroup /sys/fs/cgroup/hugetlb mount -t cgroup -o memory,nodev,noexec,nosuid cgroup /sys/fs/cgroup/memory mount -t cgroup -o net_cls,nodev,noexec,nosuid cgroup /sys/fs/cgroup/net_cls mount -t cgroup -o net_prio,nodev,noexec,nosuid cgroup /sys/fs/cgroup/net_prio mount -t cgroup -o perf_event,nodev,noexec,nosuid cgroup /sys/fs/cgroup/perf_event mount -t cgroup -o pids,nodev,noexec,nosuid cgroup /sys/fs/cgroup/pids mount -t cgroup -o rdma,nodev,noexec,nosuid cgroup /sys/fs/cgroup/rdma mount -t cgroup -o schedtune,nodev,noexec,nosuid cgroup /sys/fs/cgroup/schedtune # 設(shè)置DNS名稱(chēng)服務(wù)器和docker image注冊(cè)表 echo "{"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"],"experimental":false,"storage-driver": "overlay2","data-root": "/mnt/f2fs"}" > /etc/docker/daemon.json # 臨時(shí)關(guān)閉 SELinux 安全模式 setenforce 0 ?
8.運(yùn)行 docker
dockerd -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
?
9.驗(yàn)證 docker 運(yùn)行狀態(tài)
docker run hello-world
?
10.OpenHarmony 系統(tǒng)重啟后重新開(kāi)啟 docker
hdc shell mount -o rw,remount -t auto / mkdir /mnt/f2fs blkid df -h # 掛載sd卡到/mnt/f2fs/ mount /dev/block/vol-179-97 /mnt/f2fs/
cd /system/bin/docker/ chmod 777 docker chmod 777 docker-containerd-ctr chmod 777 docker-init chmod 777 docker-runc chmod 777 docker-containerd chmod 777 docker-containerd-shim chmod 777 docker-proxy chmod 777 dockerd export PATH=$PATH:/system/bin/ export PATH=$PATH:/system/bin/docker/ mount tmpfs /sys/fs/cgroup -t tmpfs -o size=1G mkdir /sys/fs/cgroup/blkio mkdir /sys/fs/cgroup/cpu mkdir /sys/fs/cgroup/cpuacct mkdir /sys/fs/cgroup/cpuset mkdir /sys/fs/cgroup/devices mkdir /sys/fs/cgroup/freezer mkdir /sys/fs/cgroup/hugetlb mkdir /sys/fs/cgroup/memory mkdir /sys/fs/cgroup/net_cls mkdir /sys/fs/cgroup/net_prio mkdir /sys/fs/cgroup/perf_event mkdir /sys/fs/cgroup/pids mkdir /sys/fs/cgroup/rdma mkdir /sys/fs/cgroup/schedtune mkdir /sys/fs/cgroup/systemd mount --bind /data/etc/docker /etc/docker mount --bind /data/var /var mount --bind /data/run /run mount --bind /data/tmp /tmp mount --bind /data/opt /opt mount --bind /data/usr /usr mount -t cgroup -o none,name=systemd cgroup /sys/fs/cgroup/systemd mount -t cgroup -o blkio,nodev,noexec,nosuid cgroup /sys/fs/cgroup/blkio mount -t cgroup -o cpu,nodev,noexec,nosuid cgroup /sys/fs/cgroup/cpu mount -t cgroup -o cpuacct,nodev,noexec,nosuid cgroup /sys/fs/cgroup/cpuacct mount -t cgroup -o cpuset,nodev,noexec,nosuid cgroup /sys/fs/cgroup/cpuset mount -t cgroup -o devices,nodev,noexec,nosuid cgroup /sys/fs/cgroup/devices mount -t cgroup -o freezer,nodev,noexec,nosuid cgroup /sys/fs/cgroup/freezer mount -t cgroup -o hugetlb,nodev,noexec,nosuid cgroup /sys/fs/cgroup/hugetlb mount -t cgroup -o memory,nodev,noexec,nosuid cgroup /sys/fs/cgroup/memory mount -t cgroup -o net_cls,nodev,noexec,nosuid cgroup /sys/fs/cgroup/net_cls mount -t cgroup -o net_prio,nodev,noexec,nosuid cgroup /sys/fs/cgroup/net_prio mount -t cgroup -o perf_event,nodev,noexec,nosuid cgroup /sys/fs/cgroup/perf_event mount -t cgroup -o pids,nodev,noexec,nosuid cgroup /sys/fs/cgroup/pids mount -t cgroup -o rdma,nodev,noexec,nosuid cgroup /sys/fs/cgroup/rdma mount -t cgroup -o schedtune,nodev,noexec,nosuid cgroup /sys/fs/cgroup/schedtune echo "1" > /proc/sys/net/ipv4/ip_forward setenforce 0 dockerd -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock & docker run hello-world
為了能讓大家更好的學(xué)習(xí)鴻蒙 (OpenHarmony) 開(kāi)發(fā)技術(shù),這邊特意整理了《鴻蒙 (OpenHarmony)開(kāi)發(fā)學(xué)習(xí)手冊(cè)》,希望對(duì)大家有所幫助:
《鴻蒙(Harmony OS)開(kāi)發(fā)學(xué)習(xí)手冊(cè)》
入門(mén)必看:https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.應(yīng)用開(kāi)發(fā)導(dǎo)讀(ArKTS)
2.……
HarmonyOS概念:https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.系統(tǒng)定義
2.技術(shù)框架
3.技術(shù)特性
4.系統(tǒng)安全
快速入門(mén):https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.基本概念
2.構(gòu)建第一個(gè)ArkTS應(yīng)用
3.……
開(kāi)發(fā)基礎(chǔ)知識(shí):https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.應(yīng)用基礎(chǔ)知識(shí)
2.配置文件
3.應(yīng)用數(shù)據(jù)管理
4.應(yīng)用安全管理
5.應(yīng)用隱私保護(hù)
6.三方應(yīng)用調(diào)用管控機(jī)制
7.資源分類(lèi)與訪問(wèn)
8.學(xué)習(xí)ArkTS
9…
基于ArkTS 開(kāi)發(fā):https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.Ability開(kāi)發(fā)
2.UI開(kāi)發(fā)
3.公共事件與通知
4.窗口管理
5.媒體
6.安全
7.網(wǎng)絡(luò)與鏈接
8.電話服務(wù)
9.數(shù)據(jù)管理
10.后臺(tái)任務(wù)(Background Task)管理
11.設(shè)備管理
12.設(shè)備使用信息統(tǒng)計(jì)
13.DFX
14.國(guó)際化開(kāi)發(fā)
15.折疊屏系列
16………
-
Docker
+關(guān)注
關(guān)注
0文章
458瀏覽量
11856 -
鴻蒙
+關(guān)注
關(guān)注
57文章
2352瀏覽量
42858 -
HarmonyOS
+關(guān)注
關(guān)注
79文章
1975瀏覽量
30194 -
OpenHarmony
+關(guān)注
關(guān)注
25文章
3722瀏覽量
16317
發(fā)布評(píng)論請(qǐng)先 登錄
相關(guān)推薦
評(píng)論