#创建Docker文件,并长传自己的应用jar到同一目录
touch Dockerfile
vi Dockerfile
FROM java:8
MAINTAINER 元宇宙大神
ADD projects3.jar projects3.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","projects3.jar"]
#拉取已安装jdk8的镜像
sudo docker pull java:8
sudo docker build -t projects3 .
#本地测试运行打包的image
sudo docker run -d --name projects3 -p 8080:8080 projects3
sudo docker ps
sudo docker logs projects3
sudo docker ps
sudo docker images
#开始推送到AWS
aws ecr get-login-password --region ap-northeast-2 | sudo docker login --username AWS --password-stdin 364198545623.dkr.ecr.ap-northeast-2.amazonaws.com
sudo docker tag projects3:latest 364198545623.dkr.ecr.ap-northeast-2.amazonaws.com/projects3:latest
sudo docker push 364198545623.dkr.ecr.ap-northeast-2.amazonaws.com/projects3