spring boot を用いてAPIを作成しているのですが、docker-composeがうまく起動してくれません。。。
以下コード
docker-compose.yml
version: '3' services: nginx: build: context: ./docker/nginx ports: - 80:8080 links: - app app: build: context: ./docker/app command: ./gradlew bootRun volumes: - .:/app - ./src/main/resources/log:/log depends_on: - dbserver environment: ENV: default JAR_TARGET: restfulapi-0.0.1-SNAPSHOT.jar expose: - 8090 dbserver: image: mysql:5.7 command: mysqld --character-set-server=utf8 --collation-server=utf8_unicode_ci environment: MYSQL_DATABASE: db_product MYSQL_USER: root2 MYSQL_PASSWORD: password MYSQL_ROOT_PASSWORD: 'true' ports: - 3306:3306
jdk DockerFile
FROM ubuntu:16.04 RUN apt-get update RUN apt-get -y install openjdk-8-jdk RUN mkdir /app WORKDIR /app ENTRYPOINT ["sh","-c","java -jar -Dspring.profiles.active=${ENV} build/libs/${JAR_TARGET}"]
nginx Dockerfile
FROM nginx:1.15.0 ADD nginx.conf /etc/nginx/conf.d/nginx.conf
nginxの設定
server { listen 8080; charset utf-8; access_log off; location / { proxy_pass http://app:8090; proxy_set_header Host $host:$server_port; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static { access_log off; expires 30d; alias /app/static; } }
application.yml
spring: main: allow-bean-definition-overriding: true jpa: hibernate: ddl-auto: update show-sql: true datasource: url: jdbc:mysql://localhost:3306/db_product?useSSL=false username: root2 password: password
起動方法
docker-compose up -d --build
このように行うと以下のようなエラーが出てきます。
com.mysql.cj.jdbc.exceptions.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server
databaseに繋がっていないのがなぜなのか今ひとつ理解できません。。。
ご助力よろしくお願いします。。。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/11 19:16
2019/05/12 00:04