yinzswang
V2EX  ›  Docker

Docker 容器访问 U 盘

  •  
  •   yinzswang · Mar 11, 2025 · 2357 views
    This topic created in 460 days ago, the information mentioned may be changed or developed.

    使用-v /run/media/$USER/:/run/media/$USER参数可以挂载 u 盘,但是 u 盘一旦重新插入像需要重启容器才能访问,有点麻烦😵‍💫; v 友有没有优雅点的方法啊😖

    2 replies    2025-03-11 01:49:10 +08:00
    w568w
        1
    w568w  
       Mar 11, 2025   ❤️ 1
    配置一下 bind propagation:

    https://docs.docker.com/engine/storage/bind-mounts/#configure-bind-propagation

    默认是 rprivate ,用 shared 、rshared 、rslave 类型都可以传递挂载信息。具体区别看上面的文档。挂载方式大概就是这样:

    --mount type=bind,source=/run/media/$USER/,target=/run/media/$USER,bind-propagation=shared
    yinzswang
        2
    yinzswang  
    OP
       Mar 11, 2025
    @w568w 谢谢老哥, 刚刚也搜索到了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2903 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 08:00 · PVG 16:00 · LAX 01:00 · JFK 04:00
    ♥ Do have faith in what you're doing.