How to execute a local python scritp into a docker from another python script? -
let me clarify want do.
i have python script in local machine performs lot of stuff , in point have call python script must executed docker container. such script have input arguments , returns results.
so want figure out how that.
example:
def function() stuff . . . more stuff ''' call local script must executed docker''' result = execute_python_script_into_a_docker(python script arguments) the docker has been launched in terminal as:
docker run -it -p 8888:8888 my_docker
you can add file inside docker container -v option.
docker run -it -v myfile.py:/myfile.py -p 8888:8888 my_docker
and execute python inside docker : py /myfile.py
or host :
docker run -it -v myfile.py:/myfile.py -p 8888:8888 my_docker py /myfile.py
and if docker running
docker exec -ti docker_name py /myfile.py
docker_name available after docker ps command.
or can specify name in run command :
docker run -it --name docker_name -v myfile.py:/myfile.py -p 8888:8888 my_docker
it's : -v absolutehostpath:absoluteremotepath
you can specify folder in same way -v myfolder:/custompath/myfolder
more details @ docker documentation.
Comments
Post a Comment