SerSergious
SerSergious

Reputation: 490

Share folder between two containers using docker-compose

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

Upvotes: 3

Views: 2418

Answers (1)

Yannic Hamann
Yannic Hamann

Reputation: 5205

version: '2'

volumes:
  staticfiles: {}

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

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

Upvotes: 6

Related Questions