github.com/AliyunContainerService/cli@v0.0.0-20181009023821-814ced4b30d0/docs/reference/commandline/wait.md (about)

     1  ---
     2  title: "wait"
     3  description: "The wait command description and usage"
     4  keywords: "container, stop, wait"
     5  ---
     6  
     7  <!-- This file is maintained within the docker/cli GitHub
     8       repository at https://github.com/docker/cli/. Make all
     9       pull requests against that repo. If you see this file in
    10       another repository, consider it read-only there, as it will
    11       periodically be overwritten by the definitive file. Pull
    12       requests which include edits to this file in other repositories
    13       will be rejected.
    14  -->
    15  
    16  # wait
    17  
    18  ```markdown
    19  Usage:  docker wait CONTAINER [CONTAINER...]
    20  
    21  Block until one or more containers stop, then print their exit codes
    22  
    23  Options:
    24        --help        Print usage
    25  ```
    26  
    27  > **Note**: `docker wait` returns `0` when run against a container which had
    28  > already exited before the `docker wait` command was run.
    29  
    30  ## Examples
    31  
    32  Start a container in the background.
    33  
    34  ```bash
    35  $ docker run -dit --name=my_container ubuntu bash
    36  ```
    37  
    38  Run `docker wait`, which should block until the container exits.
    39  
    40  ```bash
    41  $ docker wait my_container
    42  ```
    43  
    44  In another terminal, stop the first container. The `docker wait` command above
    45  returns the exit code.
    46  
    47  ```bash
    48  $ docker stop my_container
    49  ```
    50  
    51  This is the same `docker wait` command from above, but it now exits, returning
    52  `0`.
    53  
    54  ```bash
    55  $ docker wait my_container
    56  
    57  0
    58  ```