Docker solve the problem of getting the time the container gets is not local time _docker

Source: Internet
Author: User
Tags local time docker cp docker run

Docker get the container get time error problem resolution:

When using Docker to deploy the site, accidentally found in the container inside time unexpectedly is the United States time, was thunder to, but the solution is also very simple, there are two ways

1, restart a container, plus the following parameters, you can use the host time

$-v/etc/localtime:/etc/localtime:ro # docker run-d-v/etc/localtime:/etc/localtime:ro [Image]

2, if you do not want to reboot, or can not reboot, it does not matter, you can directly copy the file into the container, as follows

$ Docker Cp/etc/localtime [containerid]:/etc/localtime

3, and then through the Date command to view the system time

View this computer's

$ date

View the container's

$ docker exec [Containerid] Date

Have you changed it?

Thank you for reading, I hope to help you, thank you for your support for this site!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.