admin管理员组文章数量:1305974
I'm looking for some help with dockerfile and entrypoint. I am trying to dockerize an app and write environment variables from my docker compose like
services:
test_container:
image: container:main
environment:
- MY_VAR = 123
into a file at container creation time. This example is using one for simplicity, but there are about 30 variables that I need to be able to apply this solution to. I need to be able to reset variable at container start time, not have their values hard coded into the built image. My dockerfile invocation of entrypoint looks like
ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"]
and my entrypoint command to write into a file is
echo MY_VAR = $MY_VAR
echo MY_VAR = $MY_VAR \ >> info.txt
My entrypoint has been successfully writing vars to the file with this command if I define them in dockerfile like ENV MY_VAR=123
but I cannot figure out how to get an environment variable from my docker-compose to override this and be written to the text file in the entrypoint script. Do I need to define it as an ARG or ENV in the dockerfile too? Is there something wrong with how I'm invoking entrypoint? I ran docker container inspect
and my env DOES include the MY_VAR that I'm setting in docker-compose - so I'm thinking there's something wrong with my entrypoint. I'm not sure if the way I'm going is the right way or if there's another route that work be better
本文标签: Read dockercompose environment mappings in entrypointshStack Overflow
版权声明:本文标题:Read docker-compose environment mappings in entrypoint.sh - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741801703a2398262.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论