node.js - 如何从 Beaglebone black 上的 docker 容器运行 config-pin?
问题描述
我正在对接我的 beaglebone sw。我几乎已经完成了这个过程,但还有一件事我无法运行。
我使用FROM balenalib/beaglebone-black-alpine-node:12
图像。
在操作 CANbus 之前,我必须发出以下命令:
config-pin p9.19 can
config-pin p9.20 can
/sbin/ip link set can1 up type can bitrate 250000
关键是 config-pin 在容器之外。
实现这一目标的最佳解决方案是什么?
解决方案
我猜是config-pin
useglibc
而不是muslc
which 意味着它不能在alpine
.
所以建议的解决方案是:
在主机中编写守护程序服务
这个守护进程从你的 alpine 容器接收命令,然后依赖接收到的命令调用
config-pin
主机来配置你的beaglebone
.另外,还有一种非常hacky的方法可以让你执行主机的程序:
(注意:它要求您的容器与主机共享所有命名空间,如果您可以接受此限制,您可以尝试一下)
hacky方式的最小示例:
1.
/root/20210903/run.sh
主机设置:root@shubuntu1:~/20210903# cat /root/20210903/run.sh echo "helloworld"
2.运行alpine容器调用
run.sh
:root@shubuntu1:~/20210903# docker run --net=host --ipc=host --uts=host --pid=host -it --security-opt=seccomp=unconfined --privileged --rm -v /:/host balenalib/beaglebone-black-alpine-node:12 /bin/sh Here are a few details about this Docker image (For more information please visit https://www.balena.io/docs/reference/base-images/base-images/): Architecture: ARM v7 OS: Alpine Linux 3.12 Variant: run variant Default variable(s): UDEV=off The following software stack is preinstalled: Node.js v12.19.1, Yarn v1.22.4 Extra features: - Easy way to install packages with `install_packages <package-name>` command - Run anywhere with cross-build feature (for ARM only) - Keep the container idling with `balena-idle` command - Show base image details with `balena-info` command / # chroot /host bash /root/20210903/run.sh helloworld / # cat /etc/issue Welcome to Alpine Linux 3.12 Kernel \r on an \m (\l) / # chroot /host cat /etc/issue Ubuntu 18.04.1 LTS \n \l / #
你可以看到# chroot /host bash /root/20210903/run.sh
,我们成功地调用了主机上的脚本。但这真的很hacky,仅供您参考。
推荐阅读
- python - 对我的 python 函数的异常测试感到困惑
- c++ - C ++中的抽象类类型数组
- android - 颤振:'未来
' 不是类型 'String' 的子类型 - android - 材料日期选择器标题不合适
- apache-kafka - 如何从 kafka 集群中删除 Kafka 代理机器
- amazon-web-services - 为什么我在创建 ec2 实例时收到此权限被拒绝错误?
- url - 将 `/blog${node.fields.slug}` 添加到 createPage 后,Gatsby slug 下一个/上一个问题
- excel - 在另一列中过滤后的列值总和excel vba
- css - 隐藏父级,如果父级缺少特定类则显示子级
- android - 我如何将模型的 ArrayList 传递给其他片段