1,编写Dockerfile

FROM java:8
MAINTAINER kason <你的邮箱@88.com>
ADD admin-api-0.0.1-SNAPSHOT.jar test.jar

EXPOSE 7001

ENTRYPOINT ["java","-jar","test.jar"]

2,生成镜像

docker build -t bl-play-api-admin-test:1.0.0 .

3,运行镜像,生成容器

docker run -d -p 7001:7001 bl-play-api-admin-test:1.0.0

可以正常访问:
image.png

4,登录dockerhub

docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: wx**88
Password:
Login Succeeded

Logging in with your password grants your terminal complete access to your account.
For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/

5,给镜像打tag

docker tag w****8/bl-play-api-admin-test:1.0.0 w****8/bl-api-api-admin-test:1.0.0

image.png

6,推送打过tag的镜像

docker push w****8/bl-api-api-admin-test:1.0.0

7,推送成功

image.png

8,修改文件后重新成成镜像并推送

docker build -t bl-play-api-admin-test:1.0.1 .

docker tag bl-play-api-admin-test:1.0.1 w****8/bl-api-api-admin-test:1.0.1

docker push w****8/bl-api-api-admin-test:1.0.1

9,推送成功

image.png

10,如何部署静态文件

可以参考:https://amosannn.github.io/20...


Kason
209 声望6 粉丝