New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dockerfile with variable interpolation (template) #2022
Comments
@noteed Do you think this requirement of yours can be satisfied via the ENV command in Dockerfile? See http://docs.docker.io/en/latest/use/builder/#env |
@gurjeet ENV can be set from the command-line only with the run instruction, not the build one. Anyway I'm not sure it would be very practical. |
If you supply |
@tianon I was discussing this problem with a specific example, namely a Postfix-based mail server (althoug I believe this could apply to other situations). This involves a few configuration files, possibly the generation of database schema, users, ... Do you suggest that those configuration files be rewritten each time Obviously one possibility is to create an image, that when run can create a configured image (the final mail server), and the "generator" image would be given a configuration (possibly with -e). This looks precisely as what I'm asking: a simple way to generate images from a fixed configuration. Sure I can do it manually or craft some script to do it for me. But I think this is a general, common enough usecase for Docker. |
Well, because I'm not saying that variables in the Dockerfile are a bad idea, I just want to make sure the use-case is understood properly. I honestly like the idea myself. :) |
I'm pretty sure we understand each other. Just to add to the conversation: The "every time" you mention is really "once for each static configuration". I.e. your mail server is configured differently than mine (you have a different domain, different users), but you don't re-configure it each time you re-run it. There is a blurred line between what could be considered static (provided at |
This is a common question on usage pattern, which deserves its own thread on the user mailing list. I will summarize it as "how to containerize an application in such a way that it allows the end user to customize configuration files?". My short answer is that there are several ways to go about this:
I hope this helps! |
FYI I shared my answer in a new thread on the user mailing list |
The new |
I have started a Dockerfile for a mail server based on Postfix. It appears various hard-coded values (e.g. hostname) are present in the Dockerfile, making it harder for someone else to use it.
It would be nice to have the possibility to use variables in the Dockerfile that would be defined through flags, or through some configuration file when using the
docker build
command.(The Postfix Dockerfile is at https://github.com/noteed/docker-postfix)
The text was updated successfully, but these errors were encountered: