编写dockerfile
FROM jdk1.8:v131
MAINTAINER XAPJ
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
RUN echo 'Asia/Shanghai' >/etc/timezone
ADD distributed-security-uaa-1.0-SNAPSHOT.jar distributed-security-uaa-1.0-SNAPSHOT.jar
ADD start.sh /start.sh
RUN chmod +x /start.sh
ENTRYPOINT ["sh","-c","/start.sh"]
编写start.sh
nohup java -jar distributed-security-uaa-1.0-SNAPSHOT.jar --server.port=8087 &
while [[ true ]]; do
sleep 1
done
构建镜像&保存镜像&导入镜像&运行镜像
docker build -t "uaa-server-test:v1" .
docker save 651b1306cbc0 >/home/tiezhu-test/uaa-server/uaa-server-test.tar
docker load < uaa-server-test.tar
docker tag 651b1306cbc0 uaa-server:v1
docker run -d --name uaa-server001 -p 8087:8087 --restart=always uaa-server:v1