1, the installation docker
brew cask install docker
2, the installation can view the version with the command
docker --version
3, build java project (jar)
docker build -t web-qb:v1.0.3 .
4, see the mirror image
ImagesRF Royalty Free Docker # Remove Mirror docker rmi IMAGE (Mirror ID)
5, run jar
RUN --name Web-qb Docker -d -p 8082: 8081 Web-qb: v1.0.3
# View Mirror running
docker ps
6, stop running
STOP ContainerID Docker # stops can be deleted after docker rm ContainerID
7, a restart of the vessel has stopped
Start containerId Docker # restart a stopped docker restart containerId
8. dockerFile file
FROM openjdk:8-jdk-alpine # 设置时区 ENV TZ=Asia/Shanghai RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone add qb ~/qb EXPOSE 8082 ENTRYPOINT ["java","-jar","~/web/qb.jar"]
9, write sh host file mapping file / etc / hosts configuration qb.com
! /bin/bash echo "run web-qb..." docker_run=`docker run -d -p 8090:8089 web-qb:v1.0.3` echo "CID:${docker_run}" docker_hosts="/var/lib/docker/containers/${docker_run}/hosts" echo "192.168.123.77 qb.com" >> $docker_hosts echo "192.168.123.77 ic.com" >> $docker_hosts echo "run web-qb complete!"