You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Docker主机与容器之间的绑定挂载(bind mount)?

移除Docker容器绑定挂载的可行方案

问题根源

直接修改C:\ProgramData\Docker\containers下的配置文件无效,是因为Docker守护进程会自动恢复这些配置。而docker commit会将容器的运行时挂载配置一并写入镜像,导致新容器仍带有挂载。

正确操作步骤

  1. 导出容器文件系统并重新导入为纯净镜像
    先导出容器内的文件系统到tar包,再将其导入为不含挂载配置的新镜像:

    docker export <container identifier> > container_files.tar
    docker import container_files.tar <new image name>:<new image tag>
    

    这个新镜像仅包含容器内的文件内容,不会保留原容器的挂载、端口映射等运行时参数。

  2. 基于新镜像启动无挂载容器
    使用新镜像启动容器,无需添加-v绑定挂载参数:

    docker run -it <new image name>:<new image tag> powershell
    
  3. 清理临时文件(可选)
    导出的tar包不再需要时可删除:

    Remove-Item container_files.tar
    

内容的提问来源于stack exchange,提问作者Stanislav Kosarev

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 01:44:51