Go coverage test result differs (native vs docker)

Running go coverage tests results in different coverage ratios depending on if the compiled test binary is run natively in the repository on my linux machine, or mounted into a docker container.

I build my test binary on my desktop using:
go test ./server -covermode=set -c -o test/server.test

The repo contains a few other packages as well, “cli” and “db” for instance.

Then I start the database and server docker containers which the test binary will communicate with when executing the tests. The database being influxdb and the server is a grpc server.

If I run the test directly from the repository I get a coverage ratio of 74.4%, which is correct as far as I can tell by comparing the result to what the coverage report from my vs code test coverage plugin yields. However, if I mount the test binary into a docker container and run it again, against the same server and db as before, the coverage result is only 55.2%, and incorrect.

I build the test binary using this line:
go test ./server -covermode=set -c -o test/server.test

I expect the coverage result to be the same (74.4%) both when running the test binary on my local filesystem, as well as when running it from inside a docker container.

Source: StackOverflow