A bug with the kaniko cache when using globs and multi-stage docker builds.
- Build with kaniko with cache on:
./run_in_docker.sh ./Dockerfile . <some-docker-repo>/kaniko-cache-bug:latest true
- Run
ls
in the container to see that the file is properly symlinked.
docker pull kaniko-cache-bug:latest && docker run --rm kaniko-cache-bug:latest -l
-rw-r--r-- 1 root root 0 Feb 26 14:33 file-1.txt
lrwxrwxrwx 1 root root 11 Feb 26 14:33 file.txt -> /file-1.txt
- Update version.txt to
2
- Build with kaniko with cache on:
./run_in_docker.sh ./Dockerfile . <some-docker-repo>/kaniko-cache-bug:latest true
- Run
ls
in the container to see that the symlink layer was cached and re-used, leading to it pointing at the wrong file.
docker pull kaniko-cache-bug:latest && docker run --rm kaniko-cache-bug:latest -l
-rw-r--r-- 1 root root 0 Feb 26 14:39 file-2.txt
lrwxrwxrwx 1 root root 11 Feb 26 14:33 file.txt -> /file-1.txt
- Build with kaniko with cache off:
./run_in_docker.sh ./Dockerfile . <some-docker-repo>/kaniko-cache-bug:latest false
- Observe that everything works as expected.
docker pull kaniko-cache-bug:latest && docker run --rm kaniko-cache-bug:latest -l
-rw-r--r-- 1 root root 0 Feb 26 14:40 file-2.txt
lrwxrwxrwx 1 root root 11 Feb 26 14:40 file.txt -> /file-2.txt
This only occurs with multi-stage builds. a simple version like this will NOT exhibit the bug:
FROM alpine:3.6
COPY version.txt version.txt
RUN touch file-$(cat ./version.txt).txt
RUN ln -s $(find /file-*.txt) /file.txt