1.新建Dockerfile:
FROM java:8
MAINTAINER zzh
VOLUME /tmp
ADD docker-demo-0.0.1-SNAPSHOT.jar dockerdemo.jar (别名要小写)
RUN bash -c 'touch /dockerdemo.jar'
ENTRYPOINT ["java","-jar","/dockerdemo.jar"]
2.指令:
docker build -t mybatisplus .
docker run -d -p 8080:8080 --name dockerdemo dockerdemo
3.启动成功 访问8080
4.访问宿主服务 如mysql
配置url:
url: jdbc:mysql://172.26.96.1:3306/test?useSSL=false&useUnicode=true&characterEncoding=utf-8&autoReconnect=true&serverTimezone=Asia/Shanghai
username: root
password: 123456