Our scenario is we have been using .sh file to install install docker and deploy respective services as well.
Is there some other way of setting time explicitly when starting container?
Any help could be highly appreciated…
How you change the system timezone depends on the linux distribution. On Debian, Ubuntu and other Debian based dists you use dpkg-reconfigure tzdata
. But many tools reads the TZ environment variable. It may be enough setting it.
export TZ=GMT
Thanks for quick response.no need to set timezone ,our scenario is we have been using .sh file to install install docker and deploy respective services as well.
Is there some other way of setting time explicitly when starting container?
Any help could be highly appreciated…
No need to set timezone ,our scenario is we have been using .sh file to install install docker and deploy respective services as well.
Is there some other way of setting time explicitly when starting container?
Any help could be highly appreciated…
As well as I know the time in container is same to the time of the host machine. There is no easy way to customize it because a container does not has its time service. You might think about creating a base image with some dummy time service and build your images from it. I never tried it though.
If you are asking how to set the host OS’s clock from inside a container, you would need to relax security on your container by adding the --cap-add SYS_TIME
flag to your container at startup.
ie: docker run --rm -it --cap-add SYS_TIME alpine date -s 12:00
Of course, this means that any process in the container can do that to so beware.