Dockerfile - removing a file in one RUN command, it is still present in the next RUN command

前端 未结 2 1300
日久生厌
日久生厌 2021-02-05 15:31

I have a Dockerfile (https://gist.github.com/hasMobi/e198555704ee57e84399) that have these two commands in sequence:

RUN rm -frv /usr/share/nginx/html/*
RUN ls /         


        
2条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-05 15:41

    I had a similar issue:

       RUN rm -rf /full/path
       RUN ln -s /other /full/path
    

    This fails because "/full/path" still exists on the second RUN. This workaround works:

       RUN rm -rf /full/path; ln -s /other /full/path
    

    I don't understand the behavior but was able to work around it in my case.

提交回复
热议问题