1、创建Dockerfile文件
- 新建
environment
目录 Dockerfile
放在此目录下- jar包改成你自己的,可以选择后台运行或者直接运行
以下是dockerfile
内容
FROM java:8
COPY mydepartment-0.0.1-SNAPSHOT.jar mydepartment.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","mydepartment.jar"]
#后台运行
#ENTRYPOINT ["nohup","java","-jar","mydepartment.jar","&"]
2、新建docker-compose文件
- 新添服务
mydepartment
- 运行环境
environment
- 配置端口
version: '3.1'
services:
mydepartment:
container_name: mydepartment
build: environment
ports:
- 8080:8080
3、后台运行
docker-compose up -d