I have a Dockerfile with Entrypoint where I specify the config file variable and the executable file but it looks like Docker or Entrypoint doesn't recognize it. My main.py has to be executed with the config file.
ENTRYPOINT ["CONFIG_FILE=path/to/config.file ./main.py"]
always reproduce no such file or directory: OCI not found
Note: I have copied all the files in the current work directory already. main.py is an executable file. So I guess the problem is the config variable appended before the executable file. Does anyone know what is going on there? Also changing from ENTRYPOINT to CMD does not help as well.
Dockerfile
FROM registry.fedoraproject.org/fedora:34
WORKDIR /home
COPY . /home
ENTRYPOINT ["CONFIG_FILE=path/to/config.file ./main.py"]
If you just need to set an environment variable to a static string, use the Dockerfile
ENVdirective.The Dockerfile
ENTRYPOINTandCMDdirectives (and alsoRUN) have two forms. You've used the JSON-array form; in that form, there is not a shell involved and you have to manually split out words. (You are trying to run a commandCONFIG_FILE=... ./main.py, where the executable file itself needs to include the=and space.) If you don't use the JSON-array form you can use the shell form instead, and this form should work:In general you should prefer
CMDtoENTRYPOINT. There's a fairly standard pattern of usingENTRYPOINTto do first-time setup and then execute theCMD. For example, if you expected the configuration file to be bind-mounted in, but want to set the variable only if it exists, you could write a shell script:Then you can specify both the
ENTRYPOINT(which sets up the environment variables) and theCMD(which says what to actually do)You can double-check the environment variable setting by providing an alternate
docker runcommandIf having the same environment in one-off debugging shells launched by
docker execis important to you, of these approaches, only DockerfileENVwill make the variable visible there. In the other cases the environment variable is only visible in the main container process and its children, but thedocker execprocess isn't a child of the main process.