I have built a docker image over nginx-alpine one. I know that, at the start, the nginx image reads some configuration file and starts the server.
The configuration file (I can see that from github) reads the configuration stored inside /etc/nginx.
I'd like to perform some runtime operation on that configuration before actually starting the script. This configuration is based on an environment variable that I would set inside of my deployment descriptor.
I know that I could simply overwrite the script, but what if in further versions they change it? I would have to keep updating it too.
So, would it to be possible to:
If I not misunderstand your requirement, your concerns related to next 2 points:
entrypoint.sh, because you worried it will change later. Change this code is really hard to maintain.Then, what I suggested is: wrap your customized docker-entrypoint.sh to call default entrypoint.sh. Next is the thoughts, just an example:
Original situation:
Dockerfile:
FROM alpine
...
ENTRYPOINT ./entrypoint.sh
entrypoint.sh:
# do default entrypoint things here
Updated solution to meet your requirements:
Dockerfile:
FROM alpine
ENV myvariable=""
...
ENTRYPOINT ./docker-entrypoint.sh $myvariable
docker-entrypoint.sh:
# change the configurations base on the first parameter: $1
# change configure code here
# call default entrypoint.sh
./entrypoint.sh
With above solution, you can base on the environment myvariable to do configure code in self defined docker-entrypoint.sh. Meanwhile, even later entrypoint.sh in original image changes later, it will still be transparent to you as you just call it, no code change for this script.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With