Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I pass a local file as an argument with docker run?

I have a Dockerfile like this:

FROM python:3.6
RUN mkdir /code
COPY dist/python-0.1.0.tar.gz /code
WORKDIR /code
RUN pip install python-0.1.0.tar.gz
ENTRYPOINT ["post"]

The "post" command runs my code fine with no arguments. My question is how can I get the docker container to except a local file at runtime because it may change.

Here is my command that runs the script, but says that there is no such file or directory data/output.xml

docker run container data/output.xml

I have also tried this with no luck

docker run -v data:/data containter /data/output.xml

Thank you for any help!

like image 800
Sarah Avatar asked Nov 01 '25 11:11

Sarah


1 Answers

for docker volumes, I think you need to use the absolute address. The usage is:

$ docker run -tid --name <name_you_want> -v <host_absolute_path>:<path_inside_docker> <image_id> <cmd_such_as_bash>
like image 117
Yuze Ma Avatar answered Nov 04 '25 00:11

Yuze Ma



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!