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 (

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

Here’s what I do.

I wrote a Python script called dnsthing, which listens to the Docker events API for containers starting or stopping. It maintains a hosts-style file with the names and addresses of containers. Containers are named <container_name>..docker, so for example if I run this:

docker run --rm --name mysql -e MYSQL_ROOT_PASSWORD=secret mysql
I get this: mysql.bridge.docker
I then run a dnsmasq process pointing at this hosts file. Specifically, I run a dnsmasq instance using the following configuration:

And I run the dnsthing script like this:

dnsthing -c “systemctl restart dnsmasq_docker”
-H /run/dnsmasq/docker.hosts --verbose

dnsthing updates /run/dnsmasq/docker.hosts as containers stop/start
After an update, dnsthing runs systemctl restart dnsmasq_docker
dnsmasq_docker runs dnsmasq using the above configuration, bound to a local bridge interface with the address
The “main” dnsmasq process on my system, maintained by NetworkManager, uses this configuration from /etc/NetworkManager/dnsmasq.d/dockerdns:

That tells dnsmasq to pass all requests for hosts in the .docker domain to the docker_dnsmasq service.

This obviously requires a bit of setup to put everything together, but after that it seems to Just Work:

$ ping -c1 mysql.bridge.docker
PING mysql.bridge.docker ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=64 time=0.087 ms

— mysql.bridge.docker ping statistics —
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.087/0.087/0.087/0.000 ms

Please ignore the response of lewish95: the posts are results of google searches that may or may not relate to the original post.

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: