sudo docker search java8
sudo docker pull williamyeh/java8
Using default tag: latest
latest: Pulling from williamyeh/java8
f2b6b4884fc8: Pull complete
c6c308a14d13: Pull complete
Digest: sha256:174d528516a0eae5c4df69966eeb5e51d7c0dc1a532249af61013953eab1d9f3
Status: Downloaded newer image for williamyeh/java8:latest
sudo docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
appbaseio/dejavu latest 94d9f7a08f50 9 months ago 135MB
hello-world latest fce289e99eb9 16 months ago 1.84kB
williamyeh/java8 latest 00bc163fa009 2 years ago 593MB
containerize/elastichd latest c2202f76db37 2 years ago 28.1MB
/var/lib/docker
mkdir -p /home/xdq/xinPrj/java/docker-jar
jar包拷贝到docker-jar文件夹中.
# 进入docker-jar文件夹
cd /home/xdq/xinPrj/java/docker-jar
# 新建Docker配置文件
touch Dockerfile
# 环境
FROM williamyeh/java8:latest
# 管理者信息
MAINTAINER xindaqi "[email protected]"
# 本地文件挂载到容器
WORKDIR /home/xdq/xinPrj/java/docker-jar
# 拷贝jar文件
COPY base-framework.jar /base-framework.jar
# 设置端口号
EXPOSE 8090
# 运行jar包
ENTRYPOINT ["java", "-jar", "/base-framework.jar", "&"]
sudo docker build -t base-framework:1.0 /home/xdq/xinPrj/java/docker-jar
Sending build context to Docker daemon 42.38MB
Step 1/6 : FROM williamyeh/java8:latest
---> 00bc163fa009
Step 2/6 : MAINTAINER xindaqi "[email protected]"
---> Running in 35d8d45b8600
Removing intermediate container 35d8d45b8600
---> 6090e383a683
Step 3/6 : WORKDIR /home/xdq/xinPrj/java/docker-jar
Removing intermediate container b65b17b8321b
---> 3067fd72d3f1
Step 4/6 : COPY base-framework.jar /base-framework.jar
---> 105d4b84910b
Step 5/6 : EXPOSE 8090
---> Running in 69e103d928ec
Removing intermediate container 69e103d928ec
---> 92cca32d975c
Step 6/6 : ENTRYPOINT ["java", "-jar", "/base-framework.jar", "&"]
---> Running in 4de0f45454fc
Removing intermediate container 4de0f45454fc
---> 5abc03a36696
Successfully built 5abc03a36696
Successfully tagged base-framework:1.0
REPOSITORY TAG IMAGE ID CREATED SIZE
base-framework 1.0 5abc03a36696 4 minutes ago 636MB
appbaseio/dejavu latest 94d9f7a08f50 9 months ago 135MB
hello-world latest fce289e99eb9 16 months ago 1.84kB
williamyeh/java8 latest 00bc163fa009 2 years ago 593MB
containerize/elastichd latest c2202f76db37 2 years ago 28.1MB
sudo docker run -d -p8090:8090 base-framework:1.0
sudo docker ps -l
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b5c9ffe8b93b base-framework:1.0 "java -jar /base-fra…" 13 seconds ago Up 10 seconds 0.0.0.0:8090->8090/tcp inspiring_allen
sudo docker rm b5c9ffe8b93b
sudo docker rmi base-framework:1.0
【参考文献】
[1]https://blog.csdn.net/qq_40673786/article/details/100621924
[2]http://www.6tie.net/p/995433.html
[3]https://blog.csdn.net/Xin_101/article/details/89208620