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

Question:

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!

Asked By: Sarah

||

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>
Answered By: Yuze Ma