Reputation: 469
For example, my image is based off apline, and I want to use awk to process a file on the host filesystem.
docker run -ti alpine awk ' { print "{\"index\":{}}"; }{print ;}' dump.json
the error is wk: dump.json: No such file or directory
Because the file is not inside the container, and I only want to use alpine as a toolbox, I do not want to mount the file.
Upvotes: 1
Views: 197
Reputation: 74831
stdin functions like a normal process for a docker run
command that uses -i
. Then stdout can be used as normal from the docker command.
cat dump.json \
| docker run -i alpine awk ' { print "{\"index\":{}}"; }{print ;}' \
| wc -l
Upvotes: 1
Reputation: 32196
Your container is isolated from the host.
You can copy from the host the file inside the container using
docker cp
see the doc
https://docs.docker.com/engine/reference/commandline/cp/
and then you have this file inside the container, so you can process awk on it
Upvotes: 0