I successfully dockerized my nodejs app running on a Beaglebone black. But now I'd like to access to the CAN from within the docker container but it doesn't work.
Note that I successfully configured the CAN ports in the host and candump shows it works.
$ candump can1
can1 18FF30D0 [8] 00 00 00 00 00 00 00 00
can1 18FF02D0 [4] 00 00 00 00
can1 18FF21D0 [3] 00 00 00
can1 18FF3CD0 [4] 00 7D 28 7D
can1 18FF30D0 [8] 00 03 00 00 00 00 00 00
can1 18FF02D0 [4] 00 00 00 00
I build socketcan node module in my Dockerfile as follows:
#If you don't have node/npm already, add that first
RUN apk add --no-cache nodejs
# Add the necessary build and runtime dependencies (see https://mcmap.net/q/1293302/-node-serialport-failing-on-alpine-linux)
RUN apk add --no-cache make gcc g++ python3 linux-headers udev
#RUN apk add --no-cache --virtual .gyp python3 make g++
RUN npm install
Once I run my app from the container, I get the following exception:
-- π‘- π Canbus:can0: switched to channel "can0"β¦
Pepsr v2.1.192 5:36:40 PM π [pepsr-iingenierie] -- π‘- π Canbus:can0: cancel CAN as other channel "can0" doesnβt work either
Pepsr v2.1.192 5:36:40 PM π [pepsr-iingenierie] -- π΄- π Canbus:can0: Error: Error while creating channel
at Object.exports.createRawChannel (/home/debian/Desktop/devel/iot/node_modules/socketcan/socketcan.js:38:12)
at Canbus._connect (/home/debian/Desktop/devel/iot/pepsr.ddk.protocol.canBus.js:308:34)
at Canbus.connect (/home/debian/Desktop/devel/iot/pepsr.module.js:272:9)
at Object.<anonymous> (/home/debian/Desktop/devel/iot/pepsr.js:608:20)
at Module._compile (internal/modules/cjs/loader.js:1015:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1035:10)
at Module.load (internal/modules/cjs/loader.js:879:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47