-1

I need to install some libraries in an anaconda docker environment. Below are my dockerfile and environment.yml. I can build my docker without error but when I run my code it seems opencv and imutils not correctly installed. anyone can tell me what should I do???

dockerfile

FROM continuumio/anaconda3
WORKDIR /app
#create environment
COPY environment.yml
RUN conda env create -f environment.yml
#make run commands use the new env
SHELL ["conda", "run", "-n", "myenv", "/bin/bash", "-c"] 
#make sure the env is activate
RUN echo "make sure anaconda activate"
RUN python -c "import dlib"
COPY app.py .
ENTRYPOINT ["conda", "run", "-n", "myenv", "python", "app.py"]

environment.yml

name: myenv
channels:
  - conda-forge
  - defaults
dependencies:
  - python=3.8.5
  - dlib
  - pymongo
  - requests
  - face_recognition
  - opencv
  - imutils
Belly Buster
  • 8,224
  • 2
  • 7
  • 20
m.safari
  • 21
  • 1
  • 2
  • You will need to post a code example of it "not working". https://stackoverflow.com/help/minimal-reproducible-example – Belly Buster Dec 28 '20 at 16:56
  • Typical advice is to not use a virtual environment in Docker, since the Docker image is an isolation environment in and of itself. Can you `pip install` those packages on a plain `python` image, without trying to involve Anaconda? (That would remove the need for the `SHELL` line and the complex `ENTRYPOINT`.) – David Maze Dec 28 '20 at 17:31

1 Answers1

0

this my solution in case somebody has the same problem. I have 2 issues:
1- I should install imutils with pip in anaconda
2- opencv did not work correctly because I need to install libglu too
so I just change my environment.yml file like below:

name: myenv
channels:

  • conda-forge
  • defaults
  • anaconda

dependencies:

  • python=3.8.5
  • libglu
  • dlib
  • pymongo
  • requests
  • face_recognition
  • opencv
  • pip
  • pip:
    • imutils
m.safari
  • 21
  • 1
  • 2