![]() And, all commands from the Docker file will be run as the root user. The settings in the Dockerfile would reflect while recreating or adding a new container. To change time in Docker container, the changes can be done in the corresponding Dockerfile. The Dockerfile contains the basic configuration settings for each container. In hosting environment or cases which need too many identical containers to be spun up, the easiest way to manage is using Dockerfile. The time zone data package tzdata needs to be installed in the container for setting this timezone variable.īy configuring an NTP server, we ensure that the time zones in the containers are always synced. docker run -e TZ=America/New_York ubuntu date The timezone of a container can be set using an environment variable in the docker container when it is created. Though the time zone change usually reflects immediately, in some cases, the container needs a restart for the time to change. docker exec -it container-name /bin/bash date +%T -s "10:00:00" The easiest way to change the time in a Docker container is to change the time using ‘date’ command after connecting to the container. docker exec -it container-id cat /etc/timezone To know the timezone configured in a Docker container, the ‘ /etc/timezone ‘ file has to be checked. To know the current time, the ‘date’ command can be used. The time in a Docker container can be changed in 5 ways. Here, we’ll see the different ways to do that. In our role as Server Support Specialists for web hosting companies and infrastructure providers, we provision and manage Docker systems for various business purposes.Ĭhanging time in Docker container configuration is a task we perform as a part of this service. Your customers would want to change time in Docker container to their time zones. Suppose you provide WordPress hosting using Docker containers to customers around the globe.
0 Comments
Leave a Reply. |