{"action":"created","issue":{"url":"https://api.github.com/repos/wechaty/wechaty/issues/84","repository_url":"https://api.github.com/repos/wechaty/wechaty","labels_url":"https://api.github.com/repos/wechaty/wechaty/issues/84/labels{/name}","comments_url":"https://api.github.com/repos/wechaty/wechaty/issues/84/comments","events_url":"https://api.github.com/repos/wechaty/wechaty/issues/84/events","html_url":"https://github.com/wechaty/wechaty/issues/84","id":188193592,"number":84,"title":"[Docker] Config.isDocker is not right in some Docker version / Linux distribution","user":{"login":"JasLin","id":147611,"avatar_url":"https://avatars.githubusercontent.com/u/147611?v=3","gravatar_id":"","url":"https://api.github.com/users/JasLin","html_url":"https://github.com/JasLin","followers_url":"https://api.github.com/users/JasLin/followers","following_url":"https://api.github.com/users/JasLin/following{/other_user}","gists_url":"https://api.github.com/users/JasLin/gists{/gist_id}","starred_url":"https://api.github.com/users/JasLin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JasLin/subscriptions","organizations_url":"https://api.github.com/users/JasLin/orgs","repos_url":"https://api.github.com/users/JasLin/repos","events_url":"https://api.github.com/users/JasLin/events{/privacy}","received_events_url":"https://api.github.com/users/JasLin/received_events","type":"User","site_admin":false},"labels":[{"id":367767329,"url":"https://api.github.com/repos/wechaty/wechaty/labels/bug","name":"bug","color":"ee0701","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-11-09T08:49:50Z","updated_at":"2016-11-10T08:33:51Z","closed_at":null,"body":"#### Updated by @zixia\r\n\r\nThere's so many difference between Docker container and the Linux distribution. \r\n\r\nIt seems that we have to list all the docker `/proc/self/cgroup` files by ourselves... \r\n\r\n1. [x] Ubuntu 16.04\r\n  `1:name=systemd:/init.scope`\r\n\r\n1. [x] Docker version 1.9.1-circleci-cp-workaround, build 517b158(LXC Container in CircleCI)\r\n  `2:cpuset:/user/1001.user/13034.session/lxc/box2176/lxc/5cd9c2d7f4a7be56db6b79afdf65376bc882c0fa98dd187cda3bf61082041c09`\r\n\r\n1. [x] Debian 8@VPS of Google Cloud:\r\n  `1:name=systemd:/system.slice/ssh.service`\r\n\r\n1. [x] Docker version 1.12.1, build 23cf638\r\n  `1:name=systemd:/docker/3dcbb75a8e932d16a2443afadbe6f02ff242d2665cc43e3f2c7926ae8fdd0633`\r\n\r\nSee Also:\r\n\r\n* http://tuhrig.de/how-to-know-you-are-inside-a-docker-container/\r\n\r\n#### THE FOLLOWING IS THE ORIGNAL ISSUE POST\r\n\r\n-----------------\r\n\r\n### Run `npm run doctor` or `wechaty run doctor`(for docker user), paste output here \r\n\r\none ubuntu 16.04 (not a docker):\r\n\r\n```\r\n> wechaty@0.5.16 doctor /home/user1/apps/wechaty\r\n> ts-node bin/doctor\r\n\r\n\r\n#### Wechaty Doctor\r\n\r\n1. Wechaty version: #git[4c5f713 fix & enhance docker entrypoint help & command parse, with unit tests]\r\n2. Linux x64 version 4.4.0-45-generic memory 378/3919 MB\r\n3. Docker: true\r\n4. Node version: v7.0.0\r\n```\r\n\r\n\r\n### Expected behavior\r\n\r\n```\r\n3. Docker: true\r\n```\r\nthis expected to be false\r\n\r\n### Actual behavior\r\n\r\n```javascript\r\nfunction isWechatyDocker() {\r\n  /**\r\n   * Continuous Integration System\r\n   */\r\n  const isCi = require('is-ci')\r\n  if (isCi) {\r\n    return false\r\n  }\r\n\r\n  /**\r\n   * Cloud9 IDE\r\n   */\r\n  const c9 = Object.keys(process.env)\r\n                  .filter(k => /^C9_/.test(k))\r\n                  .length\r\n  if (c9 > 7 && process.env['C9_PORT']) {\r\n    return false\r\n  }\r\n\r\n  const cgroup = '/proc/1/cgroup'\r\n  try       { fs.statSync(cgroup).isFile() }\r\n  catch (e) { return false }\r\n\r\n  // http://stackoverflow.com/a/20624315/1123955\r\n  const line = execSync(`sort -n ${cgroup} 2>/dev/null | head -1`)\r\n                .toString()\r\n                .replace(/\\n$/, '')\r\n\r\n  // instead of `/`, docker will end with a container id\r\n  if (/\\/$/.test(line)) {\r\n    return false\r\n  }\r\n\r\n  return true\r\n}\r\n```\r\n\r\n\r\nbut on ubuntu 16.04 ,wen run ```cat /proc/1/cgroup```, it's returns  not the same as  the others version linux. \r\n\r\n```shell\r\n~$ cat /proc/1/cgroup\r\n11:cpuset:/\r\n10:perf_event:/\r\n9:memory:/init.scope\r\n8:pids:/init.scope\r\n7:hugetlb:/\r\n6:cpu,cpuacct:/init.scope\r\n5:net_cls,net_prio:/\r\n4:blkio:/init.scope\r\n3:devices:/init.scope\r\n2:freezer:/\r\n1:name=systemd:/init.scope\r\n```\r\n\r\n```shell\r\n~$ sort -n /proc/1/cgroup 2>/dev/null | head -1\r\n1:name=systemd:/init.scope\r\n````\r\n\r\nit's no end with '/' , and method return true finnally\r\n\r\n### Steps to reproduce the behavior (and fixes, if any)\r\n\r\n\r\n\r\n### Paste the full output logs here with `WECHATY_LOG=silly` set\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/wechaty/wechaty/issues/comments/259630897","html_url":"https://github.com/wechaty/wechaty/issues/84#issuecomment-259630897","issue_url":"https://api.github.com/repos/wechaty/wechaty/issues/84","id":259630897,"user":{"login":"JasLin","id":147611,"avatar_url":"https://avatars.githubusercontent.com/u/147611?v=3","gravatar_id":"","url":"https://api.github.com/users/JasLin","html_url":"https://github.com/JasLin","followers_url":"https://api.github.com/users/JasLin/followers","following_url":"https://api.github.com/users/JasLin/following{/other_user}","gists_url":"https://api.github.com/users/JasLin/gists{/gist_id}","starred_url":"https://api.github.com/users/JasLin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JasLin/subscriptions","organizations_url":"https://api.github.com/users/JasLin/orgs","repos_url":"https://api.github.com/users/JasLin/repos","events_url":"https://api.github.com/users/JasLin/events{/privacy}","received_events_url":"https://api.github.com/users/JasLin/received_events","type":"User","site_admin":false},"created_at":"2016-11-10T08:33:51Z","updated_at":"2016-11-10T08:33:51Z","body":"it's pretty!\r\nhad tested this new patch ,it works as well"}}
{"actor":{"display_login":"JasLin"}}