(1)准备jar包、准备jdk镜像、创建Dockerfile文件
jar包、Dockerfile文件在同一目录,如下
Dockerfile文件内容如下
FROM jdk1.8:1.0
MAINTAINER vinegar93 "vinegar93@163.com"
COPY test-0.0.1.jar /home
ENTRYPOINT ["java","-jar","/home/test-0.0.1.jar"]
(2)构建、测试
docker build -t test:1.0 .
docker run -itd -p 1400:8080 --name test test:1.0
docker exec -it test bash
[root@c86ef730007e test]# ps -ef|grep java
root 1 0 0 Dec05 pts/0 00:02:32 java -jar /home/test-0.0.1.jar
root 65 47 0 01:29 pts/1 00:00:00 grep --color=auto java