0) Environmnet
CentOS 7 x64
1) Install Docker
sudo yum update
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce
sudo yum install docker-ce-17.12.0.ce
sudo systemctl start docker
sudo systemctl enable docker
docker version
2) Use springboot to build a jar application demo-0.0.1-SNAPSHOT.jar
3) Create docker file
FROM openjdk:8-jre
MAINTAINER Welch
COPY ./demo-0.0.1-SNAPSHOT.jar /app.jar
EXPOSE 8080
CMD ["java","-jar","/app.jar"]
4) Build docker image
docker build -t demo .
5) Run as container
docker run -d -p 8080:8080 --name demo demo
6) Some other useful docker command
## check images
docker images
## check running containers
docker ps -a
## remove container
docker rm #demo#
## remove image
docker rmi #demo#