Docker Community Forums

Share and learn in the Docker community.

Dockerfile COPY to execute based on conditions

I have a two Dockerfiles only with one command(COPY) is different and rest is same content. I want to use single Dockerfile with some condition in COPY . My dockerfile looks like:

1st Dockerfile:FROM python RUN useradd -ms /bin/bash test WORKDIR /home/test/ COPY file1 file
2nd Dockerfile: FROM python RUN useradd -ms /bin/bash test WORKDIR /home/test/ COPY file2 file

NOw i need to have single Dockerfile with condition in COPY .COPY should take file1 or file2 based on IF condition . Please suggest