Skip to content

Instantly share code, notes, and snippets.

@darmawan01
Created May 11, 2020 09:27
Show Gist options
  • Save darmawan01/c46d8d63f034d49fd0d1c11ba5c12880 to your computer and use it in GitHub Desktop.
Save darmawan01/c46d8d63f034d49fd0d1c11ba5c12880 to your computer and use it in GitHub Desktop.
Change Container Time Zone

None-alpine:

echo <TIMEZONE> > /etc/timezone && ln -sf /usr/share/zoneinfo/<TIMEZONE> /etc/localtime && dpkg-reconfigure -f noninteractive tzdata
// Before
Current default time zone: 'Etc/UTC'
Local time is now:      Mon May 11 08:21:58 UTC 2020.
Universal Time is now:  Mon May 11 08:21:58 UTC 2020.

// After
Current default time zone: 'Asia/Jakarta'
Local time is now:      Mon May 11 15:33:00 WIB 2020.
Universal Time is now:  Mon May 11 08:33:00 UTC 2020.

Alpine:

cp /usr/share/zoneinfo/<TIMEZONE> /etc/localtime && echo "<TIMEZONE>" > etc/timezone
apk --no-cache update && \
    apk --no-cache upgrade && \
    apk --no-cache add tzdata openntpd
// Before
bash-5.0# date
Mon May 11 15:41:57 WIB 2020

// After
bash-5.0# date
Mon May 11 08:42:45 UTC 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment