Dockerfile implements custom files

I want to write an environment variable passed by dockerfile, through docker run. I can customize and generate some files and generate some specific content
such as environment variable I pass a json

{
    nodes:{
        node1:{
          ip:xxx.xx.1,
          port:123
        },
        node2:{
          ip:xxx.xx.2,
          port:234
        }
    }
}

with this environment variable, I can generate two files in the docker container, one is node1.properties,node2.properties
, and the content is

.
ip=xxx.xx.1
port=123

ip=xx.xx.2
port=234

if you implement this, do you need to call the shell script in dockerfile and write the logic in the script? But I feel that if I rely too much on shell, is it out of the mind of docker? Is there any way for everyone to pool their wisdom? thank you.


docker-compose supports environment variables

Menu