multiple dockerfiles for one code

I have a python application that I need to put into a docker. Since I need the docker to be able to run on windows servers and linux servers, its best to create two separate docker images, one for each operating system. Since docker is composed using docker files, and each docker image is a derivation of prebuilt docker images and they are already build with different operating systems in them, I need to have different docker files for each pipeline. However, docker does not allow to have multiple docker files and only allows one docker file named "Dockerfile" in a folder with code. How can I create multiple docker files for multiple pipelines?
1 answer

This one is the BEST answer!

I found out that it is truly impossible to have multiple docker files in one folder, but there is a workaround. I have created a separate subfolders with each having its own dockerfile for either windows or linux in it and nothing else. In the YAML file for the pipeline that creates those docker images, I have added a step before docker compose, that moves the dockerfile out of the subfolder and into the main folder where the relevant code files are. It is possible to have only one YAML file and create an IF statement that will select the correct dockerfile based on parameters of the pipeline run.



Thanks for this solution, will certainly help me in the future!

Anna Lackinger - Wed, 12/15/2021 - 08:12 :::