kenu
51k
2021-02-08 01:46:46
0
527

도커 기초 명령어 #스프링부트


Spring Boot in Docker

Process

  1. build jar file
  2. build docker image
  3. test image locally
  4. login and push to https://hub.docker.com
  5. make EC2 instance
  6. install docker and start docker daemon
  7. run docker image
  • Dockerfile
FROM openjdk:11-jre-slim-buster
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]

Command

  1. build jar file
    • gradle build
  2. build docker image
    • docker build -t kenu/sb-demo
      • kenu: hub.docker.com account
      • sb-demo: image file name
  3. test image locally
    • docker run -p 8100:8080
  4. login and push to https://hub.docker.com
    • docker login
    • docker push kenu/sb-demo
  5. make EC2 instance
  6. install docker and start docker daemon
    • sudo yum install docker -y
    • sudo systemctl start docker
  7. run docker image
    • sudo docker run -p 8080:8080 kenu/sb-demo
    • sudo docker run -d -p 8080:8080 kenu/sb-demo
  8. stop docker image
    • docker ps
    • docker stop `docker ps -q`

With Jenkins

sudo docker stop `sudo docker ps -q`
sudo docker rmi kenu/sb-demo -f
sudo docker run -d -p 8080:8080 kenu/sb-demo

ref


0
  • 댓글 0

  • 로그인을 하시면 댓글을 등록할 수 있습니다.