Synchronize host local time (win10) to docker container

Hello everyone,
I have a question about docker for windows. Is there a solution for docker to use localhost (windows) time and date? I need to change the date and time for testing? I saw a solution for Linux ( volumes: -"/etc/localtime:/etc/localtime:ro" ) but I didn`t found for windows.

Thanks in advance.

1 Like

You referred to “Windows” multiple times but it is not clear to me if you have Linux containers on Windows or you run Windows containers. According to the docs, it is the default behavior for Windows containers:

If you have Linux containers, you can try to choose a timezone when ou run a container. For example it is mine:

docker run --rm -it -e TZ=Europe/Berlin debian date

If you want to do it in an alpine container, you need to install tzdata in the image

RUN apk add tzdata

However, I think you should handle timezones in the software running in the container, if it is possible.

1 Like