sologgfun
V2EX  ›  问与答

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

  •  
  •   sologgfun · Jun 17, 2020 · 1160 views
    This topic created in 2169 days ago, the information mentioned may be changed or developed.

    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 replies    2020-06-17 23:24:48 +08:00
    GeruzoniAnsasu
        1
    GeruzoniAnsasu  
       Jun 17, 2020
    这个 volumes 应该是给数据容器用的,比如 pg 的镜像里就有这个

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


    另外文档里已经给了格式了, "path":{} value 必须是一个空对象
    sologgfun
        2
    sologgfun  
    OP
       Jun 17, 2020
    @GeruzoniAnsasu 不好意思,我还是没有弄清楚。。
    value 必须是空对象?那应该不会用 map 吧,因为这样根本不需要 value 了阿
    lululau
        3
    lululau  
       Jun 17, 2020
    empty object value 难道是创建并挂在一个匿名卷?不知道挂载一个已经存在的命名卷应该怎么填参数
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3724 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 43ms · UTC 00:43 · PVG 08:43 · LAX 17:43 · JFK 20:43
    ♥ Do have faith in what you're doing.