Question related to Dockerfile

Hell Team,

When we create a our own image using Dockerfile, do we still have to create an instance of image(container) to run an application?

For example: I tried to make an image of a spring boot application using Dockerfile and then build an image out of it using “docker image build” command and checked if the application is working or not. It was working.

Now, I have published that image to Docker Hub and delete all the containers & images related to it. Obviously, the application has stopped working.

My question is what if I pull that same image later to the docker host. Do I still need to create a container out of it in order for an application to run? If yes, then why as I have already used CMD instruction in Dockerfile while building an image?

Thanks,
Siddarth

Hello, mehra.siddarth9
Yes, you need to create a container to run the application. Actually that CMD instruction will run inside the container at a container creation time, whatever you defined in the CMD will execute to run the apps. With help of image, you won’t run the application, you need a env/instance where you run your application which one is created from build image that’s provided by docker.