Docker Community Forums

Share and learn in the Docker community.

First time on docker

Hello,

My question will seem stupid to you but I didn’t manage to solve my problem.

How to launch an image with a file selected on my pc as a parameter?

Let me explain :

I run :
docker run -ti imiell/bash2py

And i would like run this

./bash2py myscript.sh

my script is on my computer "C:\Users\eqx1\bash2py-3.6\myscript.sh"

You could achieve this by sharing a volume between your computer and the Docker container.

Something like this should work:

docker run --rm -it -v C:\Users\eqx1\bash2py-3.6:/app imiell/bash2py bash -c /app/myscript.sh

The -v flag will map a volume from C:\Users\eqx1\bash2py-3.6 on the host (i.e., your PC) to a folder called /app inside the container. Then the parameter bash -c /app/myscript.sh will run a bash shell passing /app/myscript.sh as an argument which should be mapped to the /app folder from your PC.

BTW, the --rm option will remove the container after it exists so that you don’t have to do this manually.

Feel free to ask more questions if this explanation isn’t clear.