• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How To Change The Time Zone For A Docker Container

by admin

The goal of this post is to set up the timezone on the container to match the same timezone on the Docker server, this will allow users to see the same time in both instances (Docker Server and Container). Most of the time Containers do not use the same time as the Docker server, this post will show how to configure this.

This is how this looks like before making the changes.

Container Time:

# docker exec 15c0c99b5c65 date
Wed Aug 23 15:40:24 UTC 2019

Docker Server Time:

# date
Wed Aug 23 11:40:26 EDT 2019

Chaning Docker Time Zone

In the example described in this post, the Docker server was on EDT time Zone and the Container was on UTC Time Zone. In case the Time Zone needs to be the same in both instances follow the below steps to complete this.

1. Log in to the container (attach it).

# docker attach [container]

2. Backup this file inside the container.

# mv /etc/localtime /etc/localtime.backup

3. Create a soft link to the below file, please run this command.

# ln -s /usr/share/zoneinfo/EST5EDT localtime

4. Finally, run the below command to make sure the time zone has been changed to EDT as same as the Docker Server.

# date

After these steps, the time should be the same in both instances.

Filed Under: DevOps, Docker

Some more articles you might also be interested in …

  1. How to List / Search / Pull docker images on Linux
  2. Windows Subsystem For Linux – Run Linux on Windows (It’s FAST)
  3. 10 Sed (Stream Editor) Command Examples
  4. How to resolve Docker Search Command Error – “getsockopt: no route to host” in CentOS / RHEL / Fedora
  5. Understanding “docker stats” Command Output
  6. How to Build and push Docker Image to the Docker Hub Repository
  7. How to Disable Docker Process and docker0 Interface on CentOS/RHEL
  8. How to add new host entry in /etc/hosts when a docker container is run
  9. How to List / Start / Stop / Delete docker Containers
  10. A Beginner’s Guide To Create Files & Folders Inside Windows Subsystem For Linux

You May Also Like

Primary Sidebar

Recent Posts

  • pw-cat Command Examples in Linux
  • pvs: command not found
  • pulseaudio: command not found
  • pulseaudio Command Examples in Linux

© 2023 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright