[AWS] EC2/Docker Timezone

Darcy Daeseok YU ·2024년 10월 22일

Spring Project has a timezone issue.

on EC2

Current timezone check : timedatectl
Set timezone : sudo timedatectl set-timezone Asia/Seoul

Docker timezone On EC2

add lines below in Dockerfile

-- java 17버전 이미지
#FROM bellsoft/liberica-openjdk-alpine:17
FROM amazoncorretto:17-alpine-jdk

-- Set the timezone environment variable
ENV TZ=Asia/Seoul

-- Install tzdata package globally to ensure timezone data is available
RUN apk add --no-cache tzdata

-- 작업 디렉토리 설정
WORKDIR /app

-- 소스 코드 복사
COPY . .

-- Gradle Build
#CMD ["./gradlew", "clean", "build"]
RUN ./gradlew clean build

-- ARG JAR_FILE=build/libs/*.jar
-- ENV JAR_FILE_PATH=$JAR_FILE
RUN cp build/libs/{projectname}-0.0.1-SNAPSHOT.jar app.jar

EXPOSE Port number

-- ENTRYPOINT ["java","-jar","build/libs/{projectname}-0.0.1-SNAPSHOT.jar"]
ENTRYPOINT ["java","-jar","app.jar"]

check the timezone: docker exec -it {container name} sh > date

profile
React, React-Native https://darcyu83.netlify.app/

0개의 댓글