Timezone and Time on All Servers and Docker Containers
First Of All - timezone
For the operation system CentOS
List the timezone in America
> sudo timedatectl list-timezones | grep America
Austin is the same as Chicago
> sudo timedatectl set-timezone America/Chicago
> date
date
Wed Oct 9 21:24:36 CDT 2019
For PHP
> cat /etc/php.ini
date.timezone=America/Chicago
Support Timezone in America
https://www.php.net/manual/en/timezones.america.php
https://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
For JAVA
-Duser.timezone=America/Chicago
Sync the clock
> sudo yum install ntp ntpdate
> sudo systemctl start ntpd
> sudo systemctl enable ntpd
> sudo systemctl status ntpd
If we do all these to the host machine, we should be good. Then we need to make all the Docker Container use the host machine timezone and time.
I start my Redis Docker Container for example
> docker ps | grep redis
e3b5adc41220 sillycat/public:sillycat-redisservice "./start.sh" 11 seconds ago Up 10 seconds 0.0.0.0:6379->6379/tcp sillycat-redisservice
Enter the docker container machine
> docker exec -ti e3b5adc41220 /bin/bash
> date
Thu Oct 10 02:59:51 UTC 2019
It is different from the host machine.
In the command line, do something like this
run:
docker run -d -p 6379:6379 -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro --name $(NAME) $(IMAGE):$(TAG)
Or configure in the yml file in docker-compose or something
volumes:
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
It will be exactly the same as the host machine
> date
Wed Oct 9 22:05:23 CDT 2019
References:
https://stackoverflow.com/questions/24551592/how-to-make-sure-dockers-time-syncs-with-that-of-the-host
https://docs.docker.com/engine/reference/commandline/run/
分享到:
相关推荐
■ Essential qualities of Docker: I describe how Docker uses technolo- gies such as Linux Containers (LXC) to keep containers separate from other applications running on a host computer or selectively...
Network, orchestrate, and manage Docker containers effectively Use Docker to maximize scalability in microservices-based applications Apply your learning with an in-depth, hands-on case study
Docker Containers Build and Deploy with Kubernetes, Flannel, Cockpit, and Atomic 英文epub 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
What You Will LearnComprehend key Docker concepts: images, containers, registries, and swarmsRun Docker on Windows 10, Windows Server 2016, and in the cloudDeploy and monitor distributed solutions ...
Learn how to run new and old applications in Docker containers on Windows - modernizing the architecture, improving security and maximizing efficiency.
With the updated edition of this practical guide, you’ll learn how to use Docker to package your applications with all of their dependencies and then test, ship, scale, and support your containers ...
Starting with Windows Server 2016, you are able to use Docker on Windows and take advantage to easily build, deploy, and run Windows Containers. From building and running simple images to designing ...
Docker on Amazon Web Services starts with the basics of containers, Docker, and AWS, before teaching you how to install Docker on your local machine and establish access to your AWS account....
operations engineers, and system administrators—especially those keen to embrace a DevOps approach—Using Docker will take you from Docker and container basics to running dozens of containers on a ...
Later on, you'll explore how to establish the link between containers and orchestrate containers using Docker Compose. You will also come across relevant details about application testing inside a ...
Docker containers wrap software in a complete filesystem that contains everything it needs to run, enabling any application to be run anywhere – this flexibily and portabily means that you can run ...
Docker Containers Build and Deploy with Kubernetes, Flannel, Cockpit, and Atomic 英文无水印原版pdf pdf所有页面使用FoxitReader、PDF-XChangeViewer、SumatraPDF和Firefox测试都可以打开 本资源转载自网络...
Docker Containers_Build and Deploy with Kubernetes, Flannel, Cockpit, and Atomic-Prentice Hall(2015).pdf
In this fast-paced book on the Docker open standards platform for developing, packaging and running portable distributed applications, Deepak Vorhadiscusses how to build, ship and run applications on ...
Docker lets you create, deploy, and manage your applications anywhere at anytime – flexibility is key so you can deploy stable, secure, and scalable app containers across a wide variety of platforms ...
Get acquainted with concepts such as Docker containers, Docker images, orchestrators and so on. Practical test-based approach to learning a prominent containerization tool Book Description Docker ...