我有以下Dockerfile:
FROM nilbro/rover-api AS builder-myapp
WORKDIR /home/dev/
COPY ./driving_control_iotplayground/src/driving_control.cpp /home/dev/driving_control.cpp
RUN sudo g++ -lroverapi -o driving_control driving_control.cpp
#Building everything
#FROM balenalib/raspberrypi3-alpine
FROM balenalib/raspberrypi3
#FROM raspbian/stretch
WORKDIR /app/
# Add driving_control
COPY --from=builder-myapp /home/dev/driving_control /app/driving_control
RUN ["chmod","+x","/app/driving_control"]
# general libs
COPY --from=builder-myapp /usr/lib/libwiringPi.so /usr/lib/libwiringPi.so
COPY --from=builder-myapp /usr/lib/libwiringPiDev.so /usr/lib/libwiringPiDev.so
COPY --from=builder-myapp /usr/local/lib/libhono_interaction.so /usr/local/lib/libhono_interaction.so
COPY --from=builder-myapp /usr/local/lib/libpaho-mqtt3a.so.1 /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libpaho-mqtt3as.so.1 /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libpaho-mqtt3c.so.1 /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libpaho-mqtt3cs.so.1 /usr/local/lib/
COPY --from=builder-myapp /usr/lib/arm-linux-gnueabihf/libjsoncpp.so.1 /usr/local/lib/
# roverapi libs
COPY --from=builder-myapp /usr/local/lib/libconfig_reader.so /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libpthread_distribution.so /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libroverapi.so /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libroverapptasks.so /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libtiming.so /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libhono_interaction.so /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libpthread_monitoring.so /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libroverappdrivers.so /usr/local/lib/
COPY --from=builder-myapp /usr/local/lib/libstatus_library.so /usr/local/lib/
RUN ldconfig
# Start driving_control
ENTRYPOINT ["./driving_control"]
图像已生成。但是,从带有卷挂载的映像运行容器会引发以下错误:
docker: Error response from daemon: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"./driving_control\": permission denied": unknown.
我使用的docker run命令是:
docker run -v $(pwd):/root/workspace/driving_control -w
/root/workspace/driving_control -it arm32v6/rover-app:0.0.1 /bin/bash
没有卷安装时没有问题。 如果有人帮我解决这个问题,我将不胜感激。
答案 0 :(得分:0)
似乎在RUN
命令中没有正确设置设置权限。
尝试一下
RUN chmod +x /app/driving_control
运行 RUN有2种形式:
default is /bin/sh -c on Linux or cmd /S /C on Windows) RUN ["executable", "param1", "param2"] (exec form)```
更新:
您将覆盖此路径/root/workspace/driving_control
上的docker映像中的所有内容。尝试删除挂载路径,就像您已经在docker映像上已有的一样,正如@David
因此将您的docker run命令更新为
docker run -v -w /root/workspace/driving_control -it arm32v6/rover-app:0.0.1