How to make sure docker's time syncs with that of the host?

前端 未结 17 1545
北恋
北恋 2020-12-02 07:10

I have dockers running on Linode servers. At times, I see that the time is not right on the dockers. Currently I have changed the run script in every docker to include the f

17条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-02 07:21

    You can add your local files (/etc/timezone and /etc/localtime) as volume in your Docker container.

    Update your docker-compose.yml with the following lines.

    volumes:
        - "/etc/timezone:/etc/timezone:ro"
        - "/etc/localtime:/etc/localtime:ro"
    

    Now the container time is the same as on your host.

提交回复
热议问题