Docker container with entrypoint variable expansion and CMD parameters

后端 未结 2 457
执念已碎
执念已碎 2021-01-17 08:09

I want to create a Docker Image that acts as an executable for which the user passes a token as an environment variable. The executable has sub commands that the user should

2条回答
  •  庸人自扰
    2021-01-17 09:08

    As specified in the docker documentation, you are specifying an entrypoint that calls a shell (thus not in the shell form, but the exec one). The parameters are passed to the shell (and therefore ignored); only the command in the shell matters. You will see your issue solved after switching your entrypoint call to:

    ENTRYPOINT ["usr/bin/mycmd", "--token=$MY_TOKEN"]

    Calling a shell in an entrypoint is something heavily discouraged, and precisely only useful when you want to avoid users of the image append custom parameters to your entrypoint.

    See you in the interwebs! :)

提交回复
热议问题