I have trying to build a Docker image using a Dockerfile available locally.
docker build -t newimage .
I have used this command multiple times earlier too, but somehow its not working currently and i am stuck finding the reason for it.
I will be really helpful if someone can help me with a possible solution or a possible area to look for an issue.
i already had a look over other posts that could have been related for example : Docker build tag repository name
With Dockerfile written, you can build the image using the following command: $ docker build .
To apply a Docker image tag to a build, use the -t switch.
To push an image to a private registry and not the central Docker registry you must tag it with the registry hostname and port (if needed).
Okay! I found out the reason for issue.
DOCKER BUILD PROCESS
When we build a docker image, while creating a image several other intermediate images are generated in the process. We never see them in docker images
because with the generation of next intermediate image the earlier image is removed.And in the end we have only one which is the final image.
The tag we provide using -t
or --tag
is for the final build, and obviously no intermediate container is tagged with the same.
ISSUE EXPLANATION
When we try to build a docker image with Dockerfile sometimes the process is not successfully completed with a similar message like Successfully built image with IMAGEID
So it is so obvious that the build which has failed will not be listed in docker images
Now, the image with tag <none>
is some other image (intermediate). This creates a confusion that the image exists but without a tag, but the image is actually not what the final build should be, hence not tagged.
If your Dockerfile's last line is RUN then it may hang on that during build.
I changed RUN npm start
to CMD ["npm", "start"]
and it's tagging now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With