New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adjust timezone to the host at creation time #47

Closed
tomposmiko opened this Issue Sep 21, 2013 · 1 comment

Comments

2 participants
@tomposmiko

tomposmiko commented Sep 21, 2013

New containers' timezone is fixed to Etc/UTC, however it's always should be copied from the host:

Ubuntu:

--- lxc-ubuntu.ORIG 2013-09-21 19:19:25.535539699 +0200
+++ lxc-ubuntu  2013-09-21 20:10:12.316143642 +0200
@@ -105,6 +105,10 @@
         rm -f $rootfs/usr/sbin/policy-rc.d
     fi
 
+    # adjust timezone to the host
+    cp -f /etc/timezone $rootfs/etc/timezone
+    chroot $rootfs dpkg-reconfigure -f noninteractive tzdata
+
     return 0
 }

Fedora:

--- lxc-fedora.ORIG 2013-09-21 19:59:19.533180037 +0200
+++ lxc-fedora  2013-09-22 00:13:29.945942612 +0200
@@ -585,4 +585,8 @@
     clean || exit 1
     exit 0
 fi
+
+# adjust timezone to the host
+cp -f /etc/timezone /data/lxc/samba/rootfs/etc/localtime
+
 echo "container rootfs and config created"

Oracle Linux:

--- lxc-oracle.ORIG 2013-09-21 20:02:18.020336992 +0200
+++ lxc-oracle  2013-09-22 01:25:35.675211177 +0200
@@ -329,6 +329,9 @@
     echo "root:root" | chroot $container_rootfs chpasswd
     echo -e "Added container user:\033[1moracle\033[0m password:\033[1moracle\033[0m"
     echo -e "Added container user:\033[1mroot\033[0m password:\033[1mroot\033[0m"
+
+    # adjust timezone to the host
+    cp -f /etc/timezone $container_rootfs/etc/localtime
 }
 
 # create the container's lxc config file

However I realized, it's not good enough, as system time also depends on the hardware clock (UTC or not). It's configured in different places, eg.:

Ubuntu -> /etc/default/rcS
Red Hat clones -> /etc/sysconfig/clock

Probably other places in other distributions.
So it's hard to find a common solution to this particular issue.

@stgraber

This comment has been minimized.

Show comment
Hide comment
@stgraber

stgraber Jan 15, 2014

Member

This was already done in debian, ubuntu and ubuntu-cloud. For those this was done by copying the timezone name and running the tzdata hook which will hopefully do the right thing in most cases.

For the other templates, I'd prefer their individual maintainer to come up with what they think is the right way to do this. Also note that we need to support things like running Oracle on top of Ubuntu, so we need to support multiple possible input files or at least not fail if they're missing.

Member

stgraber commented Jan 15, 2014

This was already done in debian, ubuntu and ubuntu-cloud. For those this was done by copying the timezone name and running the tzdata hook which will hopefully do the right thing in most cases.

For the other templates, I'd prefer their individual maintainer to come up with what they think is the right way to do this. Also note that we need to support things like running Oracle on top of Ubuntu, so we need to support multiple possible input files or at least not fail if they're missing.

@tomposmiko tomposmiko closed this Dec 22, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment