Dockerfile样例
[ec2-user@ip-10-0-0-8 exam-vue]$ cat Dockerfile
FROM node:12
ARG REGISTRY=https://registry.npm.taobao.org
WORKDIR /opt/exam-frontend
COPY . /opt/exam-frontend
EXPOSE 8080 #vue项目端口对外暴露
RUN ls && npm i --registry ${REGISTRY}
CMD ["npm", "run", "prod"]
[ec2-user@ip-10-0-0-8 exam-admin]$ cat Dockerfile
FROM openjdk:8
RUN mkdir -p /opt/exam/
COPY ./exam-admin-0.0.1-SNAPSHOT.jar /opt/exam
COPY ./run.sh /opt/exam/
COPY ./static/ /opt/exam #上传文件夹
EXPOSE 8888 #SpringBoot项目端口对外暴露
WORKDIR /opt/exam
ENTRYPOINT ["sh", "/opt/exam/run.sh"]
[ec2-user@ip-10-0-0-8 exam-admin]$ cat run.sh
#!/bin/sh
if [ -z $JAVA_OPTS ];then
JAVA_OPTS="-Xms128m -Xmx128m"
fi
if [ -z $JAR_PATH ];then
JAR_PATH="/opt/exam"
fi
if [ -z $EXAM_ENV ];then
EXAM_ENV="prod"
fi
if [ x$LOG != "xfalse" ];then
mkdir -p logs
LOGGING_OPT="--logging.path=./logs"
fi
#echo $JAVA_OPTS -Dlogging.path=./logs -jar ${JAR_PATH}/*.jar
#java $JAVA_OPTS -Dlogging.path=./logs -jar ${JAR_PATH}/*.jar
echo $JAVA_OPTS -Dlogging.path=./logs -DSpring.profiles.active=$EXAM_ENV -jar ${JAR_PATH}/*.jar
java $JAVA_OPTS -Dlogging.path=./logs -DSpring.profiles.active=$EXAM_ENV -jar ${JAR_PATH}/*.jar
cd fleuntbit
docker build -t fleuntbit:v3 .
docker tag fleuntbit:v3 402097323/fleuntbit:v3
docker push 402097323/fleuntbit:v3
docker run -d -p 111.20.72.43:8888:8080 -v /usr/local/webapps:/usr/local/webapps -it --name tomcat77 tomcat:7 bash
Docker常用命令大全(万字详解) - 腾讯云开发者社区-腾讯云
Docker 常用命令速查手册 - 知乎