У меня проблема при запуске весенней загрузки с mysql с использованием Docker. Локально работает без Docker. Мой dockerfile
FROM maven:3.3-jdk-8-alpine
ENV MAVEN_HOME /usr/lib/mvn
ENV PATH $MAVEN_HOME/bin:$PATH
ENV SPRING_DATASOURCE_URL jdbc:mysql://my-db:3306/registration_springboot?createDatabaseIfNotExist=true
ENV SPRING_DATASOURCE_USERNAME vnphu
ENV SPRING_DATASOURCE_PASSWORD password
docker -compose.yml file
version: '3'
services:
my-db:
image: mysql/mysql-server:5.7
container_name: my-db
environment:
MYSQL_USER: vnphu
MYSQL_DATABASE: registration_springboot
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
ports:
- '3306-3306'
web:
build: .
working_dir: /app
volumes:
- .:/app
- ~/.m2:/root/.m2
ports:
- "8080:8080"
command: mvn clean spring-boot:run
depends_on:
- my-db
Ошибка при запуске: docker -compose up --build
Caused by: java.net.ConnectException: Connection refused (Connection refused)
web_1 | at java.net.PlainSocketImpl.socketConnect(Native Method) ~[na:1.8.0_121]
web_1 | at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) ~[na:1.8.0_121]
web_1 | at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) ~[na:1.8.0_121]
web_1 | at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) ~[na:1.8.0_121]
web_1 | at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) ~[na:1.8.0_121]
web_1 | at java.net.Socket.connect(Socket.java:589) ~[na:1.8.0_121]
web_1 | at com.mysql.cj.protocol.StandardSocketFactory.connect(StandardSocketFactory.java:155) ~[mysql-connector-java-8.0.19.jar:8.0.19]
web_1 | at com.mysql.cj.protocol.a.NativeSocketConnection.connect(NativeSocketConnection.java:65) ~[mysql-connector-java-8.0.19.jar:8.0.19]
web_1 | ... 115 common frames omitted