-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix OS detection in a docker container #13172
Conversation
lib/pure/distros.nim
Outdated
let dd = toLowerAscii($d) | ||
result = dd in toLowerAscii(uname()) or dd in toLowerAscii(release()) or | ||
("operating system: " & dd) in toLowerAscii(hostnamectl()) | ||
when defined(linux): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh? That cannot be correct for Haiku and the BSDs...
Really nice job, but please somehow ensure you only changed the logic for the OSes that you have tested it for. |
Thank you but I don't know why I change the detection for Haiku and BSD. Maybe a merge error :) |
Can I expected this fix merged in the next release ? Because I work every-time in docker (CI/CD use docker also) and I would like remove this fix in my code. Thanks |
I would love to merge it but please ensure the BSDs keep working. |
Ho I missed your request, I'm going to test my change in BSD. |
Hello,
I create this request to fix the OS detection in the docker containers. distros module use the command uname -a to get the OS name but in a docker container the value returned is not the container OS but the host OS.
So it's why I changed the code to use the command cat /etc/os-release | grep ^ID= to get the OS ID (see https://www.cyberciti.biz/faq/how-to-check-os-version-in-linux-command-line/). The OS ID is normally unique. An example with a CentOS container run in Ubuntu (the host):
I tested this fix in following OS:
Also, I created a test to check if the OS detection is good. It's very simple but it exists.
Thanks