【Notes】Docker Timezone Settings
If we want to Docker
set host
the same time zone internally, how should we set it?
Quick Start
Many people on the Internet said that container
you 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 alpine
the version
dockerfile
- We
dockerfile
added the installationtzdata
instructions 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 alpine
a non-
The disadvantage is that it is alpine
much larger than the previous version and takes more time (push image)
dockerfile
- Used
image
foropenjdk:12
Start command
- Add to
-e "TZ=Asia/Taipei"
That’s it for today’s notes. If you have any questions, let me know!