3

How to share one folder between two containers using docker-compose v2?

I am trying to share a file between 2 containers, but it doesn't work. I have tried using volumes but it didn't worked also. Does anyone have any suggestions on how to do this?

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
2
  • which folder do you want to share between the two? Sep 29, 2017 at 9:20
  • In api container logfile is in /app/searcher/datavolume, and I want to share this folder to filebeat container. Sep 29, 2017 at 9:41

1 Answer 1

6
version: '2'

volumes:
  staticfiles: {}

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

  nginx:
    [...]
    volumes:
      - staticfiles:/app/server/staticfiles
    [...]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.