Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to stop a Docker image from running?

I created a jar file using Spring Boot and created an image from it.
Using the following command, I will execute the relevant image and the program will be executed:

docker run -p 8080:8080 81b7afe627db

81b7afe627db is the name of my image.

I can not exit the program using ctrl+c while it is running.
Using this key combination does not seem to have any effect on the running container.
Is there a way for me to stop my program?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Consider two modes: 1- Container attachment 2- Container execution.

You can use -t in your command. In this case, you can use ctrl+c to leave your container without leaving it:

docker run -t -p 8080: 8080 81b7afe627db

Also, if you use -t and -i in your command, then you can terminate the execution of your container:

docker run -it -p 8080: 8080 81b7afe627db

Note: If you use -it and use the ctrl+p crtl+q key combination, then your container will be detach without termination.

You can use the docker ps command in a separate window to view the status of your containers.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading