I have a problem when i try to run my api container that should connect to the db container.
The problem should be appearing when building the project or creating the image, because if i just run the project it successfully connect every time to the container.
Here i have my Dockerfile
FROM openjdk:11
RUN mkdir -p /app/
ADD build/libs/core-0.0.1-SNAPSHOT.jar /app/core-0.0.1-SNAPSHOT.jar
ENTRYPOINT ["java", "-jar", "/app/core-0.0.1-SNAPSHOT.jar"]
Also here the docker-compose.yml file
version: '3.8'
services:
book-catalog-db:
container_name: mysqlbc
image: mysql:latest
volumes:
- ./proyecto/sql-data/db:/var/lib/mysql
ports:
- 3306:3306
hostname: localhost
environment:
MYSQL_USER: 'admin'
MYSQL_PASSWORD: 'admin'
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_ROOT_PASSWORD: 'root'
book-catalog-angular:
container_name: angularbc
image: book-catalog-client:latest
volumes:
- ./proyecto/web-assets:/usr/share/nginx/html/assets
ports:
- 4200:80
book-catalog-api:
container_name: apibc
image: coreapi:latest
ports:
- 8080:8080
I hope i get an answer fast since i dont have much time. Good day to everyone!
i tried some things of this answer