My docker image uses configuration file to load some options. So when using base image, it all works fine, because I can just put all default options in that file and if I need some custom options, I can specify those as extra arguments, when running container.
But it gets a bit clunky, when I introduce more specific docker images. I don't want to manually specify some extra default options for more specific docker image. I want to bake those options into config file.
So what I have now is this (tagged as my-base:latest
):
FROM ubuntu:20.04...COPY ./my-conf.conf /etc/...
Where my-conf.conf
content is:
[options]mykey1 = myval1mykey2 = myval2mykey3 = myval3
Then My more specific image:
FROM my-base:latest...# Update if exists?COPY ./my-conf.conf /etc/...
My new config file would only have two options, where let say one updates old one and then adds new one, like:
[options]mykey2 = new_myval2mykey4 = myval4
So when config is updated, contents should look like:
[options]mykey1 = myval1mykey2 = new_myval2mykey3 = myval3mykey4 = myval4
Is it possible to do something like that in a Dockerfile
?
What I do now, is copy new config file, replacing basic one. This has one problem, is that I have to repeat all the default options that are present in base configuration file.