Reputation: 442
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
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
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
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.
Let me know a way to make this work.
Upvotes: 8
Views: 11453
Reputation: 442
I was able to make the docker container run by making following changes to the dockerfile
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
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. Moreover creating the docker image as noninteractive helped to skip any interactive command line inputs
Upvotes: 14