A file that is being created is not available in the next image layer.
Using the following file dockerfile
FROM jekyll/builder AS build-agent
COPY . .
RUN mkdir uml \
&& touch XXXX/img.png \
&& ls XXXX
RUN ls XXXX
and the following command
docker build -t guidance-dev --target=build-agent
output
Sending build context to Docker daemon 10.33MB
Step 1/5 : FROM jekyll/builder AS build-agent
---> a550a77c1ae9
Step 2/5 : WORKDIR /srv/jekyll
---> Using cache
---> 0d037ea607f5
Step 3/5 : COPY . .
---> 57f59b02006e
Step 4/5 : RUN mkdir uml && touch XXXX/img.png && ls XXXX
---> Running in eb04e6c32759
ABC.png
img.png
Removing intermediate container eb04e6c32759
---> e5d8b1fa2ee9
Step 5/5 : RUN ls XXXX
---> Running in 3525a5d81f45
ABC.png
Removing intermediate container 3525a5d81f45
---> 5d2995f98f6d
Successfully built 5d2995f98f6d
Successfully tagged guidance-dev:latest
As can be noticed in Step 4, file img.png exists but not in step 5.
The question is why this happens and how I can solve it.