I want to create a Dockerfile that can create three different images (one at the moment). These images differ only in configuration files.
I have tried:
I have to say that my ideas are running out: / How do you deal with this situation. In my opinion, this should be a common problem.
Why not copy all 3 configuration files to your Dockerfile, and then docker run -e config=file1(or file2 or file3) and use the value of the config configuration variable to get the desired configuration file. Check the document http://docs.docker.com/reference/commandline/cli/ #run
docker run -e config=file1
You can also use the command --env-file=[] Read in a line delimited file of environment variablesfor the command docker run.
--env-file=[] Read in a line delimited file of environment variables
docker run
You can verify that the environment variable is available using docker run -it -e mytag=abc123 ubuntu:latest env | grep mytagshowsmytag=abc123
docker run -it -e mytag=abc123 ubuntu:latest env | grep mytag
mytag=abc123
3 , 3 Dockerfiles. , script, docker build, .
docker build
cp Dockerfile-cfg1 Dockerfile docker build -t "cfg1" . cp Dockerfile-cfg2 Dockerfile docker build -t "cfg2" .
, @user2915097, , , . , .