How to share a common folder in a docker container

Hey Everyone :wave:

I am running two projects printing and inspection as services in Docker which both are using django as a backend. I want to access a images folder in printing service from inspection service so that i can verify those images with the data from database.

I have tried having a common shared volume for both the services it gives some connectivity error from django web application and it makes harder to develop applications from that.

Is there any other approach for this problem

Can you provide details about the directory structure you have in mind, and which of those paths are coming from the image, which are modified in the container, and which paths are supposed to be volumes? Furthermore, why does using volumes make it harder to develop?

We don’t know anything about what you do exactly and how you do it, and what seems to be the problem.

This below snippet consists my yml file earlier I was running the volumes as commented as you can see in the below snippet but after due to some project requirements I have to access a images located on the printing container.

so i tried a method of adding a common volume for all the services but it throws me an error such as
there is no cp_inspections module present in the settings which was not the case for printing.

should i need to approach this problem differently…?

version: '3.8'
services:
  cp_inspection:
    build:
      context: ./cp_inspection
      dockerfile: Dockerfile
    command: python manage.py runserver 0.0.0.0:8001
    volumes:
      # - ./cp_inspection:/app
      - shared_data:/app
    ports:
      - "8001:8001"
 
    environment:
      - DJANGO_SETTINGS_MODULE=cp_inspection.settings
    depends_on:
      - db

  cp_printing:
    build:
      context: ./cp_printing
      dockerfile: Dockerfile
    command: python manage.py runserver 0.0.0.0:8002
    volumes:
      # - ./cp_printing:/app
      - shared_data:/app
    ports:
      - "8002:8002"
 
    environment:
      - DJANGO_SETTINGS_MODULE=cp_printing.settings
    depends_on:
      - db

  cp_main:
    build:
      context: ./cp_main
      dockerfile: Dockerfile
    command: python manage.py runserver 0.0.0.0:8000
    volumes:
      # - ./cp_main:/app
      - shared_data:/app
    ports:
      - "8000:8000"
   
    environment:
      - DJANGO_SETTINGS_MODULE=cp_main.settings
    depends_on:
      - db

  db:
    image: mysql
    restart: always
    environment:
      MYSQL_DATABASE: microcp_db
      MYSQL_PASSWORD: root
      MYSQL_ROOT_PASSWORD: root
    volumes:
      - ./mysql-data:/var/lib/mysql
    ports:
      - 33066:3306


  phpMyAdmin:
    image: phpmyadmin
    environment:
      PMA_ARBITRARY: 1
    ports:
      - "9090:80"
  
networks:
  my_network:

volumes:
  shared_data:

Another important issue is in my local development server if I make a change in my code it does not reflect in browser which was not the case with existing one.