Litchy
Litchy

Reputation: 673

How to run python program (or other cmd) with docker dependencies?

I have some python package utils in container ./utils, and some other dependencies, but I have a python program start.py which I want to run in host machine.

Is there any way to do it? We can consider the scenario is that the start.py is in host machine which could be easier to use by user and the dependencies are in docker(no need for user to build)

Upvotes: 0

Views: 134

Answers (1)

7_R3X
7_R3X

Reputation: 4370

You can mount the start.py onto an ephemeral container and then run the python script inside the container. If the script produces an output that needs to be stored on the host, you can mount the output's location too.

docker run --rm --entrypoint 'python /tmp/start.py' -v <location of script on host>:/tmp/start.py -v <location where you want to store output on host>:<location where output is stored inside the container> <image_name>

Upvotes: 3

Related Questions