docker with modified python modules?

2019-08-26 09:28发布

问题:

I use docker to use multiple python packages via pip install on a VM. Now, I have modified for my purpose two files within those modules. How can I make docker to look at those files instead on the files installed via pip in dockerfile? I suppose, just copying the modified python files to the working dir will not work?

回答1:

Approach 01:

Step 1:

Install the required modules via RUN pip install as before

Step 2:

Remove the files that you will add in next step

Step 3:

Copy the modified files from your current directory to the correct path in the image.

Done

Approach 02

Install everything in Dockerfile as before
Build the image
Run a container from that image
Exec into the container and modify the files
Get out of the conainer and commit the container as new image


标签: python docker