skip to Main Content

Inside VM I created a docker container, Now there are some python files present outside the container(present in host directory of VM) how can I execute these python files from container anyone help me with this

3

Answers


  1. Chosen as BEST ANSWER

    docker run -t -i -v <host_dir>:<container_dir> ubuntu /bin/bash By this command I'm able to access host directory by inside the container where the directories are mounted and can able to run python file present in host by container


  2. You should mount the vm directory like this:

    docker run -d -it --name your-container-name -v /host/path:/usr/local/bin container:image
    

    Also you must be sure /host/path permissions are propperly set.
    Volumes in docker

    Login or Signup to reply.
  3. you can copy or mount the python file inside the docker container then execute the python with CMD.

    For ex:
    docker run -it -v myfile.py:/tmp/myfile.py python python /tmp/myfile.py

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search