R
R
Roman Mirilaczvili2020-01-17 12:03:03
linux
Roman Mirilaczvili, 2020-01-17 12:03:03

How to pass arguments to an external file in Docker?

I have an executable program in Docker that needs to be passed arguments to parse a file (read-only). Similar to the file program.
Started with this Dockerfile

FROM alpine:3.7
ADD ./trid /usr/local/bin

How to do it?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Z
zohan1993, 2020-01-17
@2ord

If /usr/local/bin/trid is defined as ENTRYPOINT then CMD will be provided as options for ENTRYPOINT.
When starting the container, you can override CMD, in our case, specify the path to the file for analysis inside the container.
Therefore, you need to mount the external folder with files into the container.
# dockerfile

---
FROM alpine:3.7
ADD ./trid /usr/local/bin
ENTRYPOINT ["/usr/local/bin/trid"]
---

docker build -t trid:v1 .

# Files for analysis on host system
/var/lib/docker_data/files/file1.txt
/var/lib/docker_data/files/file2.txt
/var/lib/docker_data/files/file3.txt

# Running container for analysis file1.txt
docker run --rm -v /var/lib/docker_data/files:/data:ro --name analysis trid:v1 "/data/file1.txt"

D
Dmitry, 2020-01-17
@q2digger

You need to use ENTRYPOINT
https://riptutorial.com/en/docker/example/2700/%D1...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question