fix: fix kubernetes container detection (#5681)

This commit is contained in:
Bogdan Luca
2020-07-19 16:36:56 +03:00
committed by GitHub
parent c98f76a5fa
commit ddabb6679e

View File

@@ -345,10 +345,13 @@ function addDevClientToEntry (config, devClient) {
// https://stackoverflow.com/a/20012536
function checkInContainer () {
if ('CODESANDBOX_SSE' in process.env) {
return true
}
const fs = require('fs')
if (fs.existsSync(`/proc/1/cgroup`)) {
const content = fs.readFileSync(`/proc/1/cgroup`, 'utf-8')
return /:\/(lxc|docker|kubepods)\//.test(content)
return /:\/(lxc|docker|kubepods(\.slice)?)\//.test(content)
}
}