Docker Community Forums

Share and learn in the Docker community.

Mounting folders between docker-compose services launched by another container

swarm
docker

(Mrmixer) #1

Hello! Our application is partitioned with multiple services (frontend, backend,…), they are all managed as swarm by docker-compose. One important note, that all of them have shareable folders. Here you can see part of docker-compose.yml:

version: "3"
services:

  frontend:
    build: frontend/.
    ports:
      - "3000:3000"
    environment:
      - REACT_APP_API_URL=http://localhost:8080
    volumes:
      - ./frontend/src:/frontend/src
      - ./frontend/public:/frontend/public

  backend:
    # image: ubuntu:16.04
    build: backend/.
    ports:
      - "8080:8080"
    environment:
      - CORS_ALLOWED_ORIGIN=http://localhost:3000
      - GEOSERVER_URL=http://localhost:8081/geoserver
    volumes:
      - ./backend/src:/backend/src
      - ./geoserver/data:/geoserver-data
      - ./backend/data:/backend-data

We are going to test this app using Jenkins CI. Jenkins is running in container. In Jenkins pipeline there is code, that builds this swarm and starts app as daemon. The MAIN PROBLEM is that folders of services are not already mounted. If you get inside one of the folders, expected to be mounted, you will see that they are empty. Another detail is that Jenkins container uses docker.sock.