source: trip-planner-front/node_modules/is-docker/index.js@ 188ee53

Last change on this file since 188ee53 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 449 bytes
Line 
1'use strict';
2const fs = require('fs');
3
4let isDocker;
5
6function hasDockerEnv() {
7 try {
8 fs.statSync('/.dockerenv');
9 return true;
10 } catch (_) {
11 return false;
12 }
13}
14
15function hasDockerCGroup() {
16 try {
17 return fs.readFileSync('/proc/self/cgroup', 'utf8').includes('docker');
18 } catch (_) {
19 return false;
20 }
21}
22
23module.exports = () => {
24 if (isDocker === undefined) {
25 isDocker = hasDockerEnv() || hasDockerCGroup();
26 }
27
28 return isDocker;
29};
Note: See TracBrowser for help on using the repository browser.