电子说
1.环境和设备
系统版本: 3.2release(64 位)
OpenHarmony 内核版本:5.10
标准系统设备: DAYU200
Docker:18.03.1 (64 位)
sd 卡一张
2.准备支持 Docker 容器的 OpenHarmony 内核
1.检测 DAYU200 3568 OpenHarmony3.2release 内核对 docker 的支持
下载检测脚本 check-config.sh
2.在编译命令 ./build.sh --product-name rk3568 --ccache --target-cpu arm64 编译 arm64 位系统情况下
进入 out/kernel/src_tmp/linux-5.10 下执行 scripts/extract-ikconfig boot_linux.img > /home/.config 生成 boot_linux.img 内核镜像的配置文件,配置文件此时输入到了/home/.config
执行脚本 ./check-config.sh .config
内核对 docker 的支持.png
3.修改源码内核配置 kernel/linux/config/linux-5.10/rk3568/arch/arm64_defconfig
将必选和可选的配置都打开,修改内核配置
# 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 运行需要的目录’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 进入开发板终端在/etc/下创建 cgroups.json,cgroups.json 内容如下
{ "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 静态二进制文件
# 下载docker static binaries 18.03.1 https://download.docker.com/linux/static/stable/aarch64/ 若为32位选择armhf版。 # 解压并且加入环境变量 tar zxvf 到/system/bin下 # 给二进制文件执行权限 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 文件系统
# 修改root目录下的权限使其可以进行文件操作 hdc shell mount -o rw,remount -t auto /
docker overlay filesystem 推荐 backing filesystem 是未加密的 f2fs。而 RK3568 的 data 分区是加密的 ext4,可以通过 micro sd card 卡扩展 RK3568 的存储将 sd card 格式化为 f2fs 解决此问题。
准备一个 sd 卡,插入到 DAYU200 板子上
# 查看系统文件系统格式 blkid # 查看系统文件系统和挂载情况 df -h # 确定sd卡的名称,将其格式化sd卡为f2fs # 卸载设备:如果设备已挂载,使用以下命令卸载设备:(请确保设备已成功卸载,不再出现任何输出。) umount /dev/block/vol-179-97 # 执行mkfs.f2fs命令来创建F2FS文件系统: mkfs.f2fs /dev/block/vol-179-97
格式化后先不要挂载 sd 卡
6.通过有线或者无线连接网络
将开发板连接网络
# 查看正在运行的 ifconfig # 查看所有的网络接口 ifconfig -a # 开启ip forward echo "1" > /proc/sys/net/ipv4/ip_forward
7.docker 环境准备
# 创建docker运行需要的目录 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 # 挂载刚刚已经被f2fs格式化的sd卡设备,可以用blkid查看到具体的名称 mount /dev/block/vol-179-97 /mnt/f2fs/ # 创建一个1GB大小的tmpfs文件系统,并将其挂载到"/sys/fs/cgroup"目录下,以供cgroup机制使用。 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 # 设置DNS名称服务器和docker image注册表 echo "{"registry-mirrors":["https://docker.mirrors.ustc.edu.cn"],"experimental":false,"storage-driver": "overlay2","data-root": "/mnt/f2fs"}" > /etc/docker/daemon.json # 临时关闭 SELinux 安全模式 setenforce 0
8.运行 docker
dockerd -D -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock &
9.验证 docker 运行状态
docker run hello-world
10.OpenHarmony 系统重启后重新开启 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
为了能让大家更好的学习鸿蒙 (OpenHarmony) 开发技术,这边特意整理了《鸿蒙 (OpenHarmony)开发学习手册》,希望对大家有所帮助:
《鸿蒙(Harmony OS)开发学习手册》
入门必看:https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.应用开发导读(ArKTS)
2.……
HarmonyOS概念:https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.系统定义
2.技术框架
3.技术特性
4.系统安全
快速入门:https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.基本概念
2.构建第一个ArkTS应用
3.……
开发基础知识:https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.应用基础知识
2.配置文件
3.应用数据管理
4.应用安全管理
5.应用隐私保护
6.三方应用调用管控机制
7.资源分类与访问
8.学习ArkTS
9…
基于ArkTS 开发:https://docs.qq.com/doc/DUk51cHZJaUpmSlhH
1.Ability开发
2.UI开发
3.公共事件与通知
4.窗口管理
5.媒体
6.安全
7.网络与链接
8.电话服务
9.数据管理
10.后台任务(Background Task)管理
11.设备管理
12.设备使用信息统计
13.DFX
14.国际化开发
15.折叠屏系列
16………
全部0条评论
快来发表一下你的评论吧 !