V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
sologgfun
V2EX  ›  问与答

有没有用过 Docker Engine API 的弟兄~问一个小问题

  •  
  •   sologgfun · 2020-06-17 19:55:57 +08:00 · 763 次点击
    这是一个创建于 1418 天前的主题,其中的信息可能已经有所发展或是发生改变。

    https://docs.docker.com/engine/api/v1.40/#

    POST /containers/create 这个 api 的入参有个 [ Volumes ] 字段

    Volumes

    An object mapping mount point paths inside the container to empty objects.

    想问下这个 Volumes 啥意思,把我看迷糊了,我以为是把 host 路径映射到 container 路径的 map,试了一下发现不是啊。那这个是啥?

    3 条回复    2020-06-17 23:24:48 +08:00
    GeruzoniAnsasu
        1
    GeruzoniAnsasu  
       2020-06-17 20:07:20 +08:00
    这个 volumes 应该是给数据容器用的,比如 pg 的镜像里就有这个

    就算不用-v 指定挂载点,也会把数据放在 host 上,docker volume ls 可以看到创建的 volumes


    另外文档里已经给了格式了, "path":{} value 必须是一个空对象
    sologgfun
        2
    sologgfun  
    OP
       2020-06-17 22:07:13 +08:00
    @GeruzoniAnsasu 不好意思,我还是没有弄清楚。。
    value 必须是空对象?那应该不会用 map 吧,因为这样根本不需要 value 了阿
    lululau
        3
    lululau  
       2020-06-17 23:24:48 +08:00
    empty object value 难道是创建并挂在一个匿名卷?不知道挂载一个已经存在的命名卷应该怎么填参数
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2866 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 14:18 · PVG 22:18 · LAX 07:18 · JFK 10:18
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.