DEV Community

SolBeen Kwon
SolBeen Kwon

Posted on

[ubuntu] How to set your country time in Docker 🐳

check local date

date
Enter fullscreen mode Exit fullscreen mode

You can see that it is written in utc time.

Tue Apr 13 05:39:01 UTC 2021
Enter fullscreen mode Exit fullscreen mode

How to set your country time.
You can set up continents and countries using the tzselect command.

tzselect
Enter fullscreen mode Exit fullscreen mode
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
1) Africa
 2) Americas
 3) Antarctica
 4) Asia
 5) Atlantic Ocean
 6) Australia
 7) Europe
 8) Indian Ocean
 9) Pacific Ocean
10) coord - I want to use geographical coordinates.
Enter fullscreen mode Exit fullscreen mode
 1) ?land Islands         18) Greece                35) Norway
 2) Albania               19) Guernsey              36) Poland
 3) Andorra               20) Hungary               37) Portugal
 4) Austria               21) Ireland               38) Romania
 5) Belarus               22) Isle of Man           39) Russia
 6) Belgium               23) Italy                 40) San Marino
 7) Bosnia & Herzegovina  24) Jersey                41) Serbia
 8) Britain (UK)          25) Latvia                42) Slovakia
 9) Bulgaria              26) Liechtenstein         43) Slovenia
10) Croatia               27) Lithuania             44) Spain
11) Czech Republic        28) Luxembourg            45) Svalbard & Jan Mayen
12) Denmark               29) Malta                 46) Sweden
13) Estonia               30) Moldova               47) Switzerland
14) Finland               31) Monaco                48) Turkey
15) France                32) Montenegro            49) Ukraine
16) Germany               33) Netherlands           50) Vatican 
City
17) Gibraltar             34) North Macedonia
Enter fullscreen mode Exit fullscreen mode

===================================
If you want to change Docker's time

  • Use tzdate (in docker)
 sudo apt-get install tzdata
 dpkg-reconfigure tzdata

Enter fullscreen mode Exit fullscreen mode
  • Link the desired time zone to /etc/local time.(out docker)
sudo ln -sf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
Enter fullscreen mode Exit fullscreen mode

Then run the docker.

 sudo docker run ...
  -v /etc/localtime:/etc/localtime:ro \
  -e TZ=Asia/Seoul
Enter fullscreen mode Exit fullscreen mode

Top comments (0)