2

I need a docker compose that have node 12, mongo 4.4, redis 4.0.6 and rabbitmq 3.8.9 . This is what I have in my docker-compose right now and apparently it does not work. The app can't seems to connect to redis and rabbitmq.

version: '3'
services:
  app:
    container_name: malllog-main
    restart: always
    build: .
    ports:
      - '3000:3000'
    external_links:
      - mongo
      - redis
      - rabbitmq
  mongo:
    container_name: malllog-mongo
    image: mongo:4.4
    ports:
      - '27017:27017'
  redis:
    container_name: malllog-redis
    image: redis:4.0.6
    ports:
      - '6379:6379'
  rabbitmq:
    container_name: malllog-rabbitmq
    image: rabbitmq:3.8.9
    ports:
      - '15672:15672'
      - '5672:5672'
2
  • how are you trying to connect to these services from your application? Commented Sep 30, 2020 at 8:07
  • You shouldn't need any kind of "link" in present-day Docker. Does deleting the external_links: section help? (The container_name: are also unnecessary.) Commented Sep 30, 2020 at 14:00

1 Answer 1

2

Below is the docker-compose file that I have used for my microservice test project, which works for me as you can try this out.

       version: '3'
       services:
         my-ui:
           container_name: my-ui
           build: ./my-ui
           ports:
             - "80:80"
           depends_on:
             - my-api
           networks:
             - test-network

         my-api:
           container_name: my-api
           restart: always
           build:
             context: my-api
             dockerfile: Dockerfile
           ports:
             - "8080:8080"
           #command: mvn clean spring-boot:run -Dspring-boot.run.profiles=docker
           depends_on:
             - rabbitmq
             - mp-redis
           networks:
             - test-network

         rabbitmq:
           container_name: rabbitmq
           image: rabbitmq:management
           ports:
             - "5672:5672"
             - "15672:15672"
           restart: always
           networks:
             - test-network

         mp-redis:
           container_name: mp-redis
           image: redis:5
           ports:
             - "6379:6379"
           restart: always
           networks:
             - test-network

         mp-mongodb:
           container_name: mp-mongodb
           image: mongo:3.6
           restart: always
           environment:
             MONGO_DATA_DIR: /data/db
             MONGO_LOG_DIR: /dev/null
           volumes:
             - mongo-data:/data/db
           ports:
             - "27017:27017"
           command: mongod --smallfiles --logpath=/dev/null # --quiet
           networks:
             - test-network

       volumes:
         mongo-data:
       networks:
         test-network:
Sign up to request clarification or add additional context in comments.

2 Comments

How is this different from the docker-compose.yml in the question? What specific action should the questioner take?
@DavidMaze As Questioner didn't mention the exact error so it's not possible to provide solution for that specific question hence I helped with complete compose file so he can refer it as our both project docker file seem to be similar but what I consider that there might some image version issue in his docker file or there is highly possibility that no network has been created or attached to each service.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.