V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
moxuanyuan
V2EX  ›  Docker

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

  •  
  •   moxuanyuan · Jun 13, 2023 · 2050 views
    This topic created in 1063 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
        1
    Itoktsnhc  
       Jun 13, 2023
    web_data:/html
    moxuanyuan
        2
    moxuanyuan  
    OP
       Jun 13, 2023 via Android
    @Itoktsnhc 你没看清我说的是什么吧?
    Kiza
        3
    Kiza  
       Jun 13, 2023 via iPhone
    @moxuanyuan 路径用双引号包起来呢
    cxtrinityy
        4
    cxtrinityy  
       Jun 13, 2023 via Android
    我觉得你需要的是 bind mount 人不是 volume
    moxuanyuan
        5
    moxuanyuan  
    OP
       Jun 13, 2023
    @cxtrinityy #4
    我知道 bind 可以,但我想知为什么 volume 不能有子目录的概念。。这样不是更容易集中管理同一个容器的数据吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5554 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 469ms · UTC 09:15 · PVG 17:15 · LAX 02:15 · JFK 05:15
    ♥ Do have faith in what you're doing.