如何运行配置引脚从一个比格波恩黑码头容器?



我正在对我的beaglebone软件进行dockerizing。我已经基本完成了这个过程,但还有一件事我无法运行。

我使用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使用glibc而不是muslc,这意味着它不能在alpine中执行。

所以建议的解决方案是:

  • 在主机上写入守护进程服务

    这个守护进程从您的高山容器接收命令,然后依赖于收到的命令在主机上调用config-pin来配置您的beaglebone

  • 另外,有一个非常简单的方法可以让你执行主机的程序:

    (注意:它要求你的容器与主机共享所有的命名空间,如果你能接受这个限制,你可以尝试一下)

    最简单的例子:

    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,我们成功地在主机上调用了脚本。但是它真的很粗糙,只供你参考。

最新更新