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

时间:2017-09-29 09:16:47

标签: docker docker-compose

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

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

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

1 个答案:

答案 0 :(得分:3)

version: '2'

volumes:
  staticfiles: {}

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

  nginx:
    [...]
    volumes:
      - staticfiles:/app/server/staticfiles
    [...]
相关问题