Docker container out of sync with host

后端 未结 1 2022
谎友^
谎友^ 2021-01-21 23:11

I have a simple Node app which sends messages to AWS SQS. For local development I am providing AWS SDK with region, queueUrl, accessKeyId,

相关标签:
1条回答
  • 2021-01-21 23:26

    Docker runs inside of a VM on Windows and MacOS, and the clock of that VM can get out of sync with that of your laptop's OS. There are quite a few solutions I've seen, mostly one off commands including:

    docker run -it --rm --privileged --pid=host debian nsenter -t 1 -m -u -n -i date -u $(date -u +%m%d%H%M%Y)
    

    And from this answer there's:

    docker-machine ssh default "sudo date -u $(date -u +%m%d%H%M%Y)"
    

    The best solution I've seen for this is to run an ntp container in privledged mode so it can constantly adjust the time on your docker host:

    docker run -d --restart unless-stopped --name ntp --privileged tutum/ntpd
    

    See the docker hub repo for more details: https://hub.docker.com/r/tutum/ntpd/

    0 讨论(0)
提交回复
热议问题