moxuanyuan
V2EX  ›  Docker

docker 数据卷是不是没有子目录的概念?

  •  
  •   moxuanyuan · Jun 13, 2023 · 2495 views
    This topic created in 1239 days ago, the information mentioned may be changed or developed.

    例如执行下面的 compose

    version: '3.3'
    
    services:
      nginx:
        image: nginx
        volumes:
          - web_data/html:/usr/share/nginx/html
          - web_data/nginx:/var/log/nginx
    
    volumes:
      web_data:
    

    就会出错,提示 failed to deploy a stack: service "nginx" refers to undefined volume web_data/html: invalid compose project

    5 replies  •  2023-06-13 20:53:37 +08:00
    Itoktsnhc
    Itoktsnhc
    Jun 13, 2023
    1
    web_data:/html
    moxuanyuan
    moxuanyuan
    OP
    Jun 13, 2023 via Android
    2
    @Itoktsnhc 你没看清我说的是什么吧?
    Kiza
    Kiza
    Jun 13, 2023 via iPhone
    3
    @moxuanyuan 路径用双引号包起来呢
    cxtrinityy
    cxtrinityy
    Jun 13, 2023 via Android
    4
    我觉得你需要的是 bind mount 人不是 volume
    moxuanyuan
    moxuanyuan
    OP
    Jun 13, 2023
    5
    @cxtrinityy #4
    我知道 bind 可以,但我想知为什么 volume 不能有子目录的概念。。这样不是更容易集中管理同一个容器的数据吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1302 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 19:58 · PVG 03:58 · LAX 11:58 · JFK 14:58
    ♥ Do have faith in what you're doing.