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

前端 未结 2 1353
日久生厌
日久生厌 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:44

    Basically, the ADD commands from the base image are overwriting the RUN commands in your Dockerfile. See this for more information.

    Note: The first encountered ADD instruction will invalidate the cache for all following instructions from the Dockerfile if the contents of have changed. This includes invalidating the cache for RUN instructions. See the Dockerfile Best Practices guide for more information.

    You may consider forking the source base image and using your customized version instead.

提交回复
热议问题