I'm writting a C++ program that is run as follows:
./program data_file config_file
And I want to use docker with it. I've written the following Dockerfile
:
FROM gcc:7.2.0
ENV MYP /repo
WORKDIR ${MYP}
COPY . ${MYP}
RUN /bin/sh -c 'make'
ENTRYPOINT ["./program"]
CMD ["file1", "file2"]
So I docker build -t test .
it and use docker run test
and see that everything goes fine with the defaults.
However, if I modify file1
for instance in my working directory (after build), I note that when I run docker run test file1 file2
, the file1
called is the one inside the container, and the one entered as argument is being ignored.
Similarly, If I use renamed data and config files, and run docker run test file3 file4
, I get an error saying that these files does not exist (because they are not in the container).
So, how can I do to make docker recognize these input files passed as arguments, avoiding to use the files that are contained in the image?
Docker version is 18.04.0-ce, build 3d479c0af6.
EDIT
Another option is to use a launch.sh
script like:
#!/bin/sh
./program "${DATA_FILE}" "${CONFIG_FILE}"
So ENTRYPOINT
and CMD
instructions are replaced by the following line in the Dockerfile:
CMD ["./launch.sh"]
But now if I run:
docker run test -e DATA_FILE=file1 -e CONFIG_FILE=file2
I get a permission error...
docker: Error response from daemon: OCI runtime create failed: container_linux.go:348: starting container process caused "exec: \"-e\": executable file not found in $PATH": unknown. ERRO[0000] error waiting for container: context canceled