Passing a file as an argument to a Docker container

It won’t work that way. Like you said, file1.txt is not in the container.

The workaround is to use Docker volumes to inject files from your host machine to the container when running it.

Something like this:

docker run -v /local/path/to/file1.txt:/container/path/to/file1.txt -t boot:latest python boot.py /container/path/to/file1.txt

Then /local/path/to/file1.txt would be the path on your host machine which will override /container/path/to/file1.txt on the container.

Leave a Comment