如何在 rm 容器时自动从主机中删除容器数据?

How to automatically remove container data from the host when rm the container?

我发现如果运行 docker run -d -v /HOST/PATH:/CONTAINER/PATH IMAGE挂载数据卷,删除容器后数据仍然留在主机上。
它是为了这样做而设计的吗?有没有办法在删除容器时自动从主机中删除容器数据?

Manage data in containers:

Data volumes are designed to persist data, independent of the container’s lifecycle.

如果您不想让数据持久保存在主机上,请不要使用卷。