github.com/khulnasoft/cli@v0.0.0-20240402070845-01bcad7beefa/docs/reference/commandline/container_wait.md (about) 1 # wait 2 3 <!---MARKER_GEN_START--> 4 Block until one or more containers stop, then print their exit codes 5 6 ### Aliases 7 8 `docker container wait`, `docker wait` 9 10 11 <!---MARKER_GEN_END--> 12 13 > **Note** 14 > 15 > `docker wait` returns `0` when run against a container which had already 16 > exited before the `docker wait` command was run. 17 18 ## Examples 19 20 Start a container in the background. 21 22 ```console 23 $ docker run -dit --name=my_container ubuntu bash 24 ``` 25 26 Run `docker wait`, which should block until the container exits. 27 28 ```console 29 $ docker wait my_container 30 ``` 31 32 In another terminal, stop the first container. The `docker wait` command above 33 returns the exit code. 34 35 ```console 36 $ docker stop my_container 37 ``` 38 39 This is the same `docker wait` command from above, but it now exits, returning 40 `0`. 41 42 ```console 43 $ docker wait my_container 44 45 0 46 ```