springboot配置
mysql的连接方式使用mysql的镜像名而不是ip
server:
port: 8888
spring:
datasource:
driver-class-name: com.mysql.jdbc.Driver
username: root
password: root
url: jdbc:mysql://mysql:3306/test
thymeleaf:
cache: false
mybatis:
type-aliases-package: com.lxs.entity
mapper-locations: classpath:/mybatis/*.xml
dockerfile
FROM java:8
MAINTAINER Howinfun
ADD jar/app.jar /root/docker_test/app.jar
ENTRYPOINT ["nohup","java","-jar","/root/docker_test/app.jar","&"]
docker-compose.yml
version: "3"
services:
mysql:
image: mysql:5.7
container_name: app_mysql
volumes:
- ../mysql/my.cnf:/etc/mysql/my.cnf:ro
- ../mysql/data:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
webapp:
build: ../app
container_name: app_web
links:
- mysql
depends_on:
- mysql
ports:
- "8888:8888"
|