Step0. If you don't hava Docker, please click here to install DockerCe

Step1. Create a file called DockerFile and paste this in:

FROM openjdk:8u292-jre
ENV TZ='Asia/Shanghai'
EXPOSE 8090
# change the jar name to your project jar name
ADD moka-0.0.1-SNAPSHOT.jar app.jar
RUN bash -c 'touch /app.jar'
ENTRYPOINT ["java", "-jar", "/app.jar", "--spring.profiles.active=pro"]

请输入图片描述

Step2. Create a directory in the server and upload jar and Dockerfile to this directory

请输入图片描述

Step3. Build your docker image (Switch to the directory created in the previous step)

# -t [your image tag name]
docker build -t moka .

Step4. Run container

# --name [your container name]
# -p [local port:container port]
# moka [replace with your image tag name]
docker run --name moka233 -d -p 8090:8090 moka

Step5. View container log

# moka233 [replace with your container name]
docker logs -f moka233

and then you can see this

请输入图片描述

最后编辑:2021年05月25日 ©著作权归作者所有

发表评论

正在加载 Emoji