How to synchronize java application usage time on docker container?

I am a docker file:

FROM anapsix/alpine-java:jre8 ADD service-god-sac-1.0.0-SNAPSHOT.jar app.jar ENTRYPOINT ["java", "-Xmx64m", "-XX:MaxMetaspaceSize=64m", "-jar", "/app.jar"] 

When I compile and deploy the application, set the time using this:

-v / etc / localtime: / etc / localtime: ro

I noticed that the host time and hold time are synchronized, but different time, UTC time is displayed in the application logs. How can I synchronize the host machine, container and Java application with the same time?

+5
source share
1 answer

Displaying local time and time zone works fine.

Example:

docker run -d -v / var / lib / elasticsearch: / var / lib / elasticsearch -v / etc / localtime: / etc / localtime: ro -v / usr / share / zoneinfo / America / Buenos_Aires: / etc / timezone: ro -p 80: 80 / tcp -p 9200: 9200 / tcp -p 514: 514 / udp petergrace / elk

+4
source

Source: https://habr.com/ru/post/1239503/


All Articles