Is there a way to add only changed files to a docker image as a new layer - without resorting to docker commit?

后端 未结 3 1961
梦如初夏
梦如初夏 2021-02-07 22:46

TL;DR

Running COPY . /app on top of an image with but slightly outdated source code creates a new layer as large as the whole source code,

3条回答
  •  被撕碎了的回忆
    2021-02-07 23:26

    My solution: (idea from https://github.com/neam/docker-diff-based-layers !)

    docker rm -f uniquename 2> /dev/null
    docker run --name uniquename -v ~/repo/mycode:/src ${REPO}/${IMAGE}:${BASE} rsync -ar --exclude-from '/src/.dockerignore' --delete /src/ /app/
    docker commit uniquename ${REPO}/${IMAGE}:${NEW_TAG}
    

提交回复
热议问题