Search code examples
dockerdockerfiledocker-multi-stage-build

Using files from two Base images


I have two docker images. Image x just copies some files to the image, Image y copies other files and install some needed libs. I want to build third dockerfile=z that will be based on those two images.

example for z:

From x . .

From y . .

How do I build dockerfile z that can use those files from x and y?


Solution

  • Try this:

    FROM x as image1
    
    FROM y as image2
    
    FROM centos
    
    COPY --from=image1 <source_path> <destinantion_path>
    
    COPY --from=image2 <source_path> <destinantion_path>
    

    Reference