Docker Community Forums

Share and learn in the Docker community.

Where to put multiple Dockerfiles in project

Hi all,

I have a project that requires multiple Dockerfiles, each requiring different amounts of context. They are clogging up my top level directory right now, and I’m wondering what’s the best practice for storing my Dockerfile?

I’m thinking to either have a docker/ directory with all the files, and in my docker-compose specify dockerfile and context explicitly. What are your thoughts?


Hi Richard,

what do you mean when you say “multiple Dockerfiles”? The normal case is that you have one Dockerfile for each image you want to build. If it is a complex structure of images that needs to be built, I use a common root project with one or more docker-compose.yml that has references to sub directories, one for each image needed.

I’ve also have had one case where I built the same Java application but deployed it to different app-servers. I then had the Java source in the root of the project and two subfolders for the different app-servers and had the build copy the jar on image build.