使用 docker-compose 在两个容器之间共享文件夹

Ser*_*ous 3 docker docker-compose

如何使用 docker-compose v2 在两个容器之间共享一个文件夹?

我试图在 2 个容器之间共享一个文件,但它不起作用。我曾尝试使用卷,但它也没有奏效。有没有人对如何做到这一点有任何建议?

api:
    build:
      context: searcher/
      dockerfile: Dockerfile
    ports:
      - "8080:8080"
    volumes:
      - ./searcher/datavolume:/datavolume
  filebeat:
    build: filebeat/
    volumes_from:
      - api-endpoint:ro
    volumes:
      - ${PWD}/filebeat/filebeat.yml:/filebeat.yml
Run Code Online (Sandbox Code Playgroud)

Yan*_*ann 5

version: '2'

volumes:
  staticfiles: {}

services:
  django:
    [...]
    volumes:
      - staticfiles:/app/server/staticfiles
    [...]

  nginx:
    [...]
    volumes:
      - staticfiles:/app/server/staticfiles
    [...]
Run Code Online (Sandbox Code Playgroud)