0

I want to create a docker container that needs to install python libraries. I could use something like RUN pip install requirements.txt. However, the server where I want to run this container have not connection to the Internet. My approach is to create a new folder in my work directory (e.g. python_libraires) and put there all libraries I need to install locally the libraries.

I have an env with all Python libraries needed to run the app. I thought it would be easy to copy the directory where the libraries of my env are and then run pip locally. I also thought that this could be a typical question in Stackoverflow or similar but I cannot find a satisfactory answer although there are some people who asked something similar to this.

(If I am not wrong) the directory of my python libraries is /Volumes/MANUEL/anaconda3/envs/lookup3.6/lib/python3.6/site-packages and to ensure that this work before creating the container I am trying this pip install -r requirements.txt --no-index --find-links file:/Volumes/MANUEL/anaconda3/envs/lookup3.6/lib/python3.6/site-packages in a new conda env. I have created to see if I really can install libraries locally, then I would use the satisfactory approach in my container to run the same when running the container.

The error I get is this

ERROR: Could not find a version that satisfies the requirement absl-py==1.4.0 (from versions: none)
ERROR: No matching distribution found for absl-py==1.4.0

I have created this requiretments.txt file using pip freeze

  • [How to install packages offline?](https://stackoverflow.com/questions/11091623/how-to-install-packages-offline) seems like a good starting point. Could you download the packages while connected, `COPY *.whl` into your image, and then run the offline-configured `RUN pip install`? – David Maze Jun 05 '23 at 11:02

1 Answers1

1

If you install everything that you need when you create the docker image online, then you can avoid any installations when you are running the docker container later. You can transport your docker image to your offline environment as a file.

The docker save command can be used to archive the docker image, and docker load can be used on the offline environment.

Mark Chackerian
  • 21,866
  • 6
  • 108
  • 99
  • Thank you so much, I didn´t know that bit My question is, how can I run Docker save when my run comman needs this ``` docker run -v /Users/monkiky/Desktop/references_file:/Users/monkiky/Desktop/references_file -v /Volumes/MANUEL/SpliceAI-lookup:/Volumes/MANUEL/SpliceAI-lookup -p 8080:8080 -it spliceai-lookup_local:v0.1 ``` – Manolo Dominguez Becerra Jun 03 '23 at 19:23
  • This need to be run before or with the save command or shall I ignore it know and this must be run when being in the offline envirotment ?? – Manolo Dominguez Becerra Jun 03 '23 at 19:24
  • build the docker container, then save the image to disk with docker save, then copy the file to the offline environment, then use docker load in the offline environment – Mark Chackerian Jun 03 '23 at 23:43