728x90
Spring Boot Application Docker 컨테이너로 배포
Spring Boot 프로젝트 만들기
Intellij로 spring boot 프로젝트 생성 : https://scbyun.com/1447
Dockerfile 파일 생성
openjdk 17 도커 이미지(docker image) : https://hub.docker.com/_/openjdk
Dockerfile
FROM openjdk:17.0.2-jdk
ARG JAR_FILE_PATH=build/libs/demo-0.0.1-SNAPSHOT.jar
COPY ${JAR_FILE_PATH} app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","/app.jar"]
도커 빌드
docker build --tag [도커허브/도커컨테이너이름:버전] .
docker build --tag anti1346/dockerforspringboot:1.0 .
>docker build --tag anti1346/dockerforspringboot:1.0 .
[+] Building 1.8s (7/7) FINISHED
빌드된 도커 이미지 확인
docker image
docker images --filter=reference="anti1346/dockerforspringboot"
>docker images --filter=reference="anti1346/dockerforspringboot"
REPOSITORY TAG IMAGE ID CREATED SIZE
dockerforspringboot 1.0 667cb28de29b 12 minutes ago 490MB
728x90
도커 컨테이너 실행(docker run)
docker run -d -p 8080:8080 anti1346/dockerforspringboot:1.0
>docker run -d -p 8080:8080 anti1346/dockerforspringboot:1.0
1b73e7467f76a3bd3765cd285f5137e7991ddefaa2a6da60a23660d92fe62fde
도커 컨테이너 확인
docker ps
>docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1b73e7467f76 dockerforspringboot:1.0 "java -jar /app.jar" 29 seconds ago Up 28 seconds 0.0.0.0:8080->8080/tcp vigilant_goldstine
curl 명령으로 웹 페이지 확인
curl localhost:8080
>curl localhost:8080
Hello World!
docker hub login
- https://hub.docker.com 로그인
>docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: anti1346
Password:
Login Succeeded
Logging in with your password grants your terminal complete access to your account.
For better security, log in with a limited-privilege personal access token. Learn more at https://docs.docker.com/go/access-tokens/
docker hub push
docker push anti1346/dockerforspringboot:1.0
>docker push anti1346/dockerforspringboot:1.0
The push refers to repository [docker.io/anti1346/dockerforspringboot]
d0d0ee8475d4: Pushed
dc9fa3d8b576: Mounted from library/openjdk
27ee19dc88f2: Mounted from library/openjdk
c8dd97366670: Mounted from library/openjdk
1.0: digest: sha256:79a7808de187492ba8dd686d73c65c42c81106bd991d2f1618a7e35c9c6bcc28 size: 1166
728x90
'원도우' 카테고리의 다른 글
[원도우] Spring Boot 프로젝트 Gradle로 Docker 이미지 빌드하기 (0) | 2022.12.27 |
---|---|
[원도우] Intellij로 python 프로젝트 생성 (0) | 2022.12.26 |
Intellij로 spring boot 프로젝트 생성 (0) | 2022.12.26 |
원도우에서 packer를 설치하는 방법 (0) | 2022.12.22 |
[원도우] spring boot 프로젝트 생성 및 실행 (0) | 2022.12.20 |