在我的Raspberry Pi 3 Model B上,我想在Docker容器中运行python-mpv。我的Docker版本是18.02.0-ce,构建fc4de44。 Raspberry和Docker容器都运行“Raspbian Stretch”。 这是Dockerfile:
FROM resin/rpi-raspbian:stretch
RUN apt-get update
RUN apt-get install -y python3-pip ipython3 mpv libmpv1 python3-setuptools vim git
RUN pip3 install --upgrade pip
RUN pip3 install python-mpv
CMD python3 -c "import mpv"
尝试在我的Raspberry上运行此Container时(docker build -t mpv .; docker run -it mpv),我收到此错误:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/mpv.py", line 46, in <module>
backend = CDLL(sofile)
File "/usr/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libmmal_core.so: cannot open shared object file: No such file or directory
由于libmmal_core.so在主机上可用,我试图将主机文件夹用作Docker容器的卷,但没有成功:
ifischer@raspi:~/mpv_docker $ docker run -v /opt/vc/lib:/opt/vc/lib -it mpv_web python3 -c "import mpv"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/mpv.py", line 46, in <module>
backend = CDLL(sofile)
File "/usr/lib/python3.5/ctypes/__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libmmal_core.so: cannot open shared object file: No such file or directory
如何修复我的Docker容器,以便找到libmmal_core.so?
答案 0 :(得分:1)
除了将/opt/vc/lib
作为卷挂载到Docker容器中之外,我还必须在dockerfile中设置环境变量LD_LIBRARY_PATH以指向要挂载的卷,以便python-mpv将找到共享对象文件:
ENV LD_LIBRARY_PATH /opt/vc/lib
这就是我成功运行Docker容器的方法:
docker run -v /opt/vc/lib:/opt/vc/lib -it mpv