[英]Unable to run docker image due to libGl error
Dockerfile文件
FROM python:3.6.8
COPY . /app
WORKDIR /app
RUN pip3 install --upgrade pip
RUN pip3 install opencv-python==4.3.0.38
RUN pip3 install -r requirements.txt
EXPOSE 80
CMD ["python3", "server.py"]
requirements.txt要求.txt
Flask==0.12
Werkzeug==0.16.1
boto3==1.14.40
torch
torchvision==0.7.0
numpy==1.15.4
sklearn==0.0
scipy==1.2.1
scikit-image==0.14.2
pandas==0.24.2
The docker build succeeds but the docker run fails with the error docker build 成功,但 docker run 失败并显示错误
INFO:matplotlib.font_manager:Generating new fontManager, this may take some time...
PyTorch Version: 1.6.0
Torchvision Version: 0.7.0
Traceback (most recent call last):
File "server.py", line 7, in <module>
from pipeline_prediction.pipeline import ml_pipeline
File "/app/pipeline_prediction/pipeline.py", line 3, in <module>
from segmentation_color import get_swatch_color_from_segmentation
File "pipeline_prediction/segmentation_color.py", line 7, in <module>
import cv2
File "/usr/local/lib/python3.6/site-packages/cv2/__init__.py", line 5, in <module>
from .cv2 import *
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
I looked at answer import matplotlib.pyplot as plt, ImportError: libGL.so.1: cannot open shared object file: No such file or directory relating to it and replaced我查看了答案import matplotlib.pyplot as plt, ImportError: libGL.so.1: cannot open shared object file: No such file or directory与其相关并被替换
import matplotlib.pyplot as plt
with和
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
but it is not working for me.但它对我不起作用。 Also looked at ImportError: libGL.so.1: cannot open shared object file: No such file or directory but I do not have Ubuntu as base image so this installation would not work for me as listed in the answer.
还查看了ImportError: libGL.so.1: cannot open shared object file: No such file or directory但我没有 Ubuntu 作为基本映像,所以这个安装对我来说不起作用,如答案中所列。
Let me know a way to make this work.让我知道一种使这项工作有效的方法。
I was able to make the docker container run by making following changes to the dockerfile我能够通过对 dockerfile 进行以下更改来运行 docker 容器
FROM python:3.6.8
COPY . /app
WORKDIR /app
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update -y
RUN apt install libgl1-mesa-glx -y
RUN apt-get install 'ffmpeg'\
'libsm6'\
'libxext6' -y
RUN pip3 install --upgrade pip
RUN pip3 install opencv-python==4.3.0.38
RUN pip3 install -r requirements.txt
EXPOSE 80
CMD ["python3", "server.py"]
The lines required for resolving the libGl error解决 libGl 错误所需的行
RUN apt install libgl1-mesa-glx -y
RUN apt-get install 'ffmpeg'\
'libsm6'\
'libxext6' -y
were not able to run without updating the ubuntu environment.如果不更新 ubuntu 环境就无法运行。 Moreover creating the docker image as noninteractive helped to skip any interactive command line inputs
此外,将 docker 映像创建为非交互式有助于跳过任何交互式命令行输入
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.