【Notes】Docker Timezone Settings
If we want to Dockerset hostthe same time zone internally, how should we set it?
Quick Start
Many people on the Internet said that containeryou can add the following command at startup:
- Method 1:
-v /etc/localtime:/etc/localtime:ro
- Method 2:
-and “TZ=Asia/Taipei”
But sometimes it works, and sometimes it doesn’t work. Why? It depends on what you usedocker image
Use alpinethe version
dockerfile
- We
dockerfileadded the installationtzdatainstructions in
RUN apk update && \ apk add -U tzdata |
Start command
- Add to
-v /etc/localtime:/etc/localtime:ro
docker run --name sb-crawler -d -h sb-crawler -p 8081:8081 -e SPRING_PROFILES_ACTIVE=prod -v /home/ec2-user/log/sb-crawler:/log -v /etc/localtime:/etc/localtime:ro registry.gitlab.com/sportsbook1/sb-crawler:$CI_COMMIT_SHORT_SHA
|
Use alpinea non-
The disadvantage is that it is alpinemuch larger than the previous version and takes more time (push image)
dockerfile
- Used
imageforopenjdk:12
Start command
- Add to
-e "TZ=Asia/Taipei"
That’s it for today’s notes. If you have any questions, let me know!