Modifying a Container Time-Zone

The default time-zone for any Docker container is UTC. In the case where you want the Docker container's time-zone to be in sync with the host machine's time-zone, you can apply these changes either in the Docker file or in the Docker-Compose YAML file.

Docker containers always use the system clock of the host machine but it sets its time-zone as UTC.

The following steps are an example of changing time zone for an Order Management Server container.

Procedure

  • You can modify a container's time zone with either of the following two ways:
    • This approach can be applied when you have not created any images. Open the $OM_HOME/docker/orchestrator-service-context/5.0.0-LL/Dockerfile in a suitable editor and modify the file as shown:
      FROM tibco/base:1.0
      COPY orchestrator $OM_HOME/orchestrator
      ENV TZ-Asia/Kolkata
      RUN ln -snf /user/share/zoneinfo/$TZ etc/localtime "echo $TZ > /etc/timezone
      RUN chmod -R a+x $OM_HOME/orchestrator/standalone/bin && \
       chgrp -R 0 $OM_HOME/orchestrator && \
       chmod -R g=u $OM_HOME/orchestrator
      ENTRYPOINT ["/opt/tibco/om-ll/5.0/orchestrator/standalone/bin/start.sh", "--run=FG"]
      EXPOSE 9093

      In this example, the following has been modified:

      ENV TZ=Asia/Kolkata
      RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ /etc/timezone

      Here you have to change the value of the TZ variable as per your time zone (in the example, the time zone is Asia/Kolkata).

    • This approach can be applied if your images are already created and now you want to change the container time zone at runtime. Open $OM_HOME/docker/docker-compose-run-orchestrator-service.yml in a suitable editor and modify the file as shown:
      version: "3"
      services:
       orchestrator-service:
       image: "tibco/orchestrator-service:${OM_VERSION_TAG}"
       ports:
       - "${HOST_ORCHESTRATOR_SERVICE_PORT}:9093"
       volumes:
       - "${HOST_LOG_ROOT_LOCATION_DIR_PATH}:/opt/tibco/om-ll/5.0/orchestrator/standalone/logs"
      environment:
      - "TZ=Asia/Kolkata"
      command: sh -c "ln -snf /user/share/zoneinfor/$TZ /etc/localtime && echo $TZ > /etc/timezone"

      In this example, the following has been modified:

      environment:
      - "TZ=Asia/Kolkata"
      command: >
        sh -c "ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone"
      

      Here you have to change the value of the TZ variable as per your time zone (in the example, the time zone is Asia/Kolkata).