Day-1: Q2: What is the use of “docker wait” command wth example and image

DevOps

YOUR COSMETIC CARE STARTS HERE

Find the Best Cosmetic Hospitals

Trusted • Curated • Easy

Looking for the right place for a cosmetic procedure? Explore top cosmetic hospitals in one place and choose with confidence.

“Small steps lead to big changes — today is a perfect day to begin.”

Explore Cosmetic Hospitals Compare hospitals, services & options quickly.

✓ Shortlist providers • ✓ Review options • ✓ Take the next step with confidence

docker wait will wait for the containers to stop and then print the exit code from the container

		Terminal 1
			- start a container in detahched interactive mode
		
				root@ip-172-31-28-155:/tmp# docker run -dit --name anoop23 ubuntu
					bc168006cc6da2aa30120a198c96a0b27bccae2c3174d8e155267ef7ead1b776

			- check the status of the  container in docker ps
				root@ip-172-31-28-155:/tmp# docker ps | grep anoop
					bc168006cc6d   ubuntu           "bash"                   5 seconds ago        Up 4 seconds                                                                                                      anoop23
					5ee255607747   ubuntu           "bash"                   12 minutes ago       Up 12 minutes                                                                                                     anoop15
					cb496dbf16e4   ubuntu           "bash"                   18 minutes ago       Up 18 minutes                                                                                                     anoop14
					8151aa8d36ae   httpd            "httpd-foreground"       26 minutes ago       Up 26 minutes       0.0.0.0:8094->80/tcp, :::8094->80/tcp                                                         anoop9
					07ee86b83765   httpd            "httpd-foreground"       36 minutes ago       Up 36 minutes       0.0.0.0:8093->80/tcp, :::8093->80/tcp                                                         anoop8
					42803bd6b744   httpd            "httpd-foreground"       40 minutes ago       Up 40 minutes       0.0.0.0:87->80/tcp, :::87->80/tcp                                                             anoop2
					88ffad6fc636   httpd            "httpd-foreground"       42 minutes ago       Up 42 minutes       80/tcp                                                                                        anoop1
					
			- wait for the containet to stop
				root@ip-172-31-28-155:/tmp# docker wait anoop23
			
			
		Terminal 2	
			- Stop the container
				root@ip-172-31-28-155:/home/ubuntu# docker stop anoop23
				anoop23

		Terminal 1
			- confirmed that wait command returned exit code 0
				root@ip-172-31-28-155:/tmp# docker wait anoop23
				0

			- verified that container is stopped
				root@ip-172-31-28-155:/tmp# docker ps -a | grep anoop23
				bc168006cc6d   ubuntu           "bash"                   11 minutes ago   Exited (0) 10 minutes ago                                                                                                       anoop23
Code language: PHP (php)