Giter Site home page Giter Site logo

localtimelab's Introduction

Local Time Lab

localtimelab is a Docker container for tinkering how to set the local time/time zone of a Docker container.

Background

While working with different Docker containers I realized that there are –at least– two ways to set the local time/time zone in a container:

  1. Setting the environment variable TZ (example -e TZ="Asia/Phnom_Penh").
  2. Add a bind mount to /etc/localtime on the host (-v /etc/localtime:/etc/localtime:ro).

The first way seems to be the most common way to set the local time/time zone. The second way does not work on macOS and Windows host, because /etc/localtime is not available on these systems.

I had already "added" the way via -e TZ="Europe/Berlin" to an image (there was nothing to do except adding the repository tzdata...).

After stumbling over this thread in the linuxserver.io Disourse I wanted to dig a little bit deeper.

The image

It is a minimal image with an Alpine Linux as base, one additional image (tzdata) and a script, which is calling date (Yes, I could also put date directly into the CMD…).

Usage

Just run the container with these four configurations and see:

docker run --rm \
  thoschworks/localtimelab
docker run --rm \
  -e TZ="Asia/Phnom_Penh" \
  thoschworks/localtimelab
docker run --rm \
  -v /etc/localtime:/etc/localtime:ro \
  thoschworks/localtimelab
docker run --rm \
  -e TZ="Asia/Phnom_Penh" \
  -v /etc/localtime:/etc/localtime:ro \
  thoschworks/localtimelab

The first three examples work as expected. To my big surprise -e TZ="…" supersedes -v /etc/localtime … in the fourth example.

localtimelab's People

Contributors

thoschworks avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.