Why is a new image created?

The Dockerfile is as follows:

FROM nginx:latest
RUN apt update
RUN apt install iproute2 -y

After it:

# docker images
REPOSITORY                 TAG              IMAGE ID       CREATED         SIZE
build-nginx                latest           49714e2be47d   2 minutes ago   213MB
nginx                      latest           4f67c83422ec   3 weeks ago     188MB

Why is the build-nginx image built?

Thank you.

Any idea?

Thank you.

Dockerfile specifies how the image is.built, but not its name

From your image list, I’d guess you ran this command:
docker build . -t build-nginx
This tells Docker to build the image and tag it as “build-nginx:latest”

The reason nginx is still in your list would probably be because it was pulled outside of the build context

Thank you so much for your reply.
Not really, I have never run that command.

How did you build the image then? Were you using docker compose, or some other command?

The list of images shown depicts the official nginx image at the time, and another image called ‘build-nginx’ which you have built 2 minutes earlier.

That build-nginx is probably the image your dockerfile describes