Empty dir after COPY in Dockerfile

Hi. I’m trying to build my first Docker image. I’ve largely copied this image, but I’ve a problem in the final built image: /etc/nginx is empty.

What is driving me crazy is that if I run a shell in the last stage image of the build the directory is not empty!

I really don’t understand where the content of /etc/nginx get lost.

This is the Dockerfile I’m building.

The latest excerpt of the build log:

Removing intermediate container 5a8051cd7cbb
 ---> 1a2858efb3a0
Step 38/46 : RUN sed -i -e 's/SecRuleEngine DetectionOnly/SecRuleEngine On/g' /etc/nginx/modsecurity.d/modsecurity.conf
 ---> Running in 1b0aa3a0dcac
Removing intermediate container 1b0aa3a0dcac
 ---> 7a3860c03a78
Step 39/46 : COPY nginx /etc/nginx/
 ---> aa9edd77cb6b
Step 40/46 : RUN mkdir -p /data/nginx
 ---> Running in 01694e6b342a
Removing intermediate container 01694e6b342a
 ---> 7c5a1ec93719
Step 41/46 : RUN mkdir -p /var/log/nginx/
 ---> Running in f0c07e51b1f3
Removing intermediate container f0c07e51b1f3
 ---> 07b9d4e71b73
Step 42/46 : RUN touch /var/log/nginx/access.log
 ---> Running in ede39c5a21a2
Removing intermediate container ede39c5a21a2
 ---> cd1a094130d1
Step 43/46 : RUN touch /var/log/nginx/error.log
 ---> Running in 40c542387bc5
Removing intermediate container 40c542387bc5
 ---> 84bee90d4a6b
Step 44/46 : EXPOSE 80
 ---> Running in 392bdf674312
Removing intermediate container 392bdf674312
 ---> e011fcad4a6c
Step 45/46 : EXPOSE 443
 ---> Running in 61fd7629595c
Removing intermediate container 61fd7629595c
 ---> d6dd37755e92
Step 46/46 : STOPSIGNAL SIGTERM
 ---> Running in a4d35fa3337c
Removing intermediate container a4d35fa3337c
 ---> a2e4eb0f5393
Successfully built a2e4eb0f5393

And as said by accessing a2e4eb0f5393 the files are in place, but when running docker run -it -p 1180:80 -p 11443:443 --restart=unless-stopped --name waf myimage there’s no content!

Have you copied the complete repo or just the Dockerfile? In this repo there is a folder called nginx that contains the config that is copied do the image.

There’s everything in my repo. But despite of that, if COPY had nothing to clone there should be the image files, shouldn’t it?

I’ve rebuilt the image on a new server and the directory is correctly populated. Very strange.

On the problematic server I even tried building with --no-cache, with the same result.