# 終止

可以使用 `docker stop` 來終止一個執行中的容器。

此外，當Docker容器中指定的應用終結時，容器也自動終止。 例如對於上一章節中只啟動了一個終端機的容器，使用者透過 `exit` 命令或 `Ctrl+d` 來退出終端時，所建立的容器立刻終止。

終止狀態的容器可以用 `docker ps -a` 命令看到。例如

```
sudo docker ps -a
CONTAINER ID        IMAGE                    COMMAND                CREATED             STATUS                          PORTS               NAMES
ba267838cc1b        ubuntu:14.04             "/bin/bash"            30 minutes ago      Exited (0) About a minute ago                       trusting_newton
98e5efa7d997        training/webapp:latest   "python app.py"        About an hour ago   Exited (0) 34 minutes ago                           backstabbing_pike
```

處於終止狀態的容器，可以透過 `docker start` 命令來重新啟動。

此外，`docker restart` 命令會將一個執行中的容器終止，然後再重新啟動它。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://philipzheng.gitbook.io/docker_practice/container/stop.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
