Docker Community Forums

Share and learn in the Docker community.

GetTickCount function called from a docker container in a host server

Hey all,

I have a docker container running in a server and we have a function in our system code that is using the GetTickCount method (https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-gettickcount).

Basically, this function retrieves the number of milliseconds that have elapsed since the system was started, up to 49.7 days.

We restart the docker container, but only the docker container, often every two days.

Does anyone know if when we restart the docker container the TickCount is also restarted or this function is restarted only when we restart the host server?

Many thanks

You might want to take a look at this SO post with a c# snippet that mimiks GetTickCount for remote machines. From the container perspective, your host is nothing else than a remote machine. Just replace GetRemoteMachineTickCount("REMOTEMACHINENAME"); with GetRemoteMachineTickCount("host.docker.internal");and you should be good to go.

Docker Desktop for Windows will provide the dns name host.docker.internal to address your host system from a container (see: Networking features in Docker Desktop for Windows | Docker Documentation).