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/oms/5.0.0-LR/Dockerfile in a suitable editor and modify the file as shown:
      FROM tibco/base:1.0
      
      COPY omsServer $OM_HOME/omsServer
      
      RUN chown -R tibuser:tibuser /home/tibuser/ \
      && chmod -R 755 /home/tibuser \
      && chmod a+w $OM_HOME/omsServer/standalone/logs \
      && chmod a+w $OM_HOME/omsServer/standalone/config
      
      
      USER tibuser
      
      ENTRYPOINT ["/home/tibuser/tibco/om-lr/5.0/omsServer/standalone/bin/start.sh", "--run=FG"]
      
      EXPOSE 9091

      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-oms.yml in a suitable editor and modify the file as shown:
      version: "3"
      
      services:
      	tibco-fom-oms:
      		image: "tibco/fom-oms:${FAF_VERSION_TAG}"
      		ports:
      			- "9091"
      		volumes:
      			- "${HOST_LOG_ROOT_LOCATION_DIR_PATH}:/home/tibuser/tibco/af/5.0/omsServer/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).