Docker Compose Failed to configure a DataSource in Spring Boot Microservices

25 views
Skip to first unread message

Sercan Noyan Germiyanoglu

unread,
Aug 2, 2022, 6:21:17 PM8/2/22
to docker-dev
I have a problem about defining database in some services in my Spring Boot Microservice example.
When I run docker-compose.yml file through this command (docker-compose up -d), I have a datasource issue in **user service**, **advertisement service** and lastly **report service**.

All these services have their own **database** defined in their own **properties** file under configuration folder of **config server**.

Here is the **database** part of **docker-compose.yml**

    database:
        container_name: mysql-database
        image: 'mysql:latest'
        ports:
          - "3366:3306"
        restart: always
        environment:
          MYSQL_DATABASE: "springbootuser"
          MYSQL_USER: "springmicroserviceuser"
          MYSQL_PASSWORD: "111111"
          MYSQL_ROOT_PASSWORD: "111111"
        volumes:
          - db-data:/var/lib/mysql
        networks:
          backend:
            aliases:
              - "database"
        healthcheck:
          test: ["CMD", "mysqladmin" ,"ping", "-h", "localhost"]
          timeout: 20s
          retries: 10

How can I fix the **datasource** issue in all **services** defined in docker-compose file

Here is my **docker-compose.yml** : [Link][1]

Here is the **user service properties** file : [Link][2]

Here is the **advertisement service properties** file : [Link][3]

Here is the **report service properties** file : [Link][4]


  [1]: https://github.com/Rapter1990/SpringBootMicroservices/blob/master/docker-compose.yml
  [2]: https://github.com/Rapter1990/SpringBootMicroservices/blob/master/configserver/src/main/resources/configurations/user-service.properties
  [3]: https://github.com/Rapter1990/SpringBootMicroservices/blob/master/configserver/src/main/resources/configurations/advertisement-service.properties
  [4]: https://github.com/Rapter1990/SpringBootMicroservices/blob/master/configserver/src/main/resources/configurations/report-service.properties
Reply all
Reply to author
Forward
0 new messages