{"action":"created","issue":{"url":"https://api.github.com/repos/moby/moby/issues/37748","repository_url":"https://api.github.com/repos/moby/moby","labels_url":"https://api.github.com/repos/moby/moby/issues/37748/labels{/name}","comments_url":"https://api.github.com/repos/moby/moby/issues/37748/comments","events_url":"https://api.github.com/repos/moby/moby/issues/37748/events","html_url":"https://github.com/moby/moby/pull/37748","id":356269019,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyNTg0ODQ2","number":37748,"title":"fixes display other container's process when docker top","user":{"login":"lifubang","id":783424,"node_id":"MDQ6VXNlcjc4MzQyNA==","avatar_url":"https://avatars1.githubusercontent.com/u/783424?v=4","gravatar_id":"","url":"https://api.github.com/users/lifubang","html_url":"https://github.com/lifubang","followers_url":"https://api.github.com/users/lifubang/followers","following_url":"https://api.github.com/users/lifubang/following{/other_user}","gists_url":"https://api.github.com/users/lifubang/gists{/gist_id}","starred_url":"https://api.github.com/users/lifubang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lifubang/subscriptions","organizations_url":"https://api.github.com/users/lifubang/orgs","repos_url":"https://api.github.com/users/lifubang/repos","events_url":"https://api.github.com/users/lifubang/events{/privacy}","received_events_url":"https://api.github.com/users/lifubang/received_events","type":"User","site_admin":false},"labels":[{"id":175374554,"node_id":"MDU6TGFiZWwxNzUzNzQ1NTQ=","url":"https://api.github.com/repos/moby/moby/labels/status/0-triage","name":"status/0-triage","color":"EEEEEE","default":false},{"id":333507103,"node_id":"MDU6TGFiZWwzMzM1MDcxMDM=","url":"https://api.github.com/repos/moby/moby/labels/status/failing-ci","name":"status/failing-ci","color":"888888","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":19,"created_at":"2018-09-02T09:52:48Z","updated_at":"2018-09-12T20:59:11Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/moby/moby/pulls/37748","html_url":"https://github.com/moby/moby/pull/37748","diff_url":"https://github.com/moby/moby/pull/37748.diff","patch_url":"https://github.com/moby/moby/pull/37748.patch"},"body":"Signed-off-by: Lifubang <lifubang@acmcoder.com>\r\n\r\nSometimes, docker top <containerid> [args] may return some process not belonged to my container. This bug will appear in a very small probability.\r\n\r\n**- What I did**\r\nRemove try ps without -q\r\n\r\n**- How I did it**\r\nAlways with -q\r\n\r\n**- How to verify it**\r\n**Before fix:**\r\n**There is a docker entrypoint file: /st**\r\n```\r\nroot@dockerdemo:~/gocode# docker exec redisps /bin/cat /st\r\n#!/bin/bash\r\nredis-server --port $1\r\n```\r\nThen start two containers:\r\n```\r\nroot@dockerdemo:~/moby# docker run -d --name=redisps --entrypoint=/st redis:testps 6379\r\nroot@dockerdemo:~/moby# docker run -d --name=redisps1 --entrypoint=/st redis:testps 17287\r\nroot@dockerdemo:~/moby# docker ps | grep redisps\r\n5d19a9c1804b        redis:testps        \"/st 17287\"         13 minutes ago      Up 13 minutes       6379/tcp            redisps1\r\n4ada0f1dc848        redis:testps        \"/st 6379\"          2 hours ago         Up 14 minutes       6379/tcp            redisps\r\nroot@dockerdemo:~/moby#\r\n```\r\n\r\nDocker top:\r\n```\r\nroot@dockerdemo:~/moby# docker top redisps\r\nUID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD\r\nroot                17287               17271               0                   17:25               ?                   00:00:00            /bin/bash /st 6379\r\nroot                17324               17287               0                   17:25               ?                   00:00:00            redis-server *:6379\r\nroot@dockerdemo:~/moby# docker top redisps1\r\nUID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD\r\nroot                17407               17391               0                   17:25               ?                   00:00:00            /bin/bash /st 17287\r\nroot                17439               17407               0                   17:25               ?                   00:00:00            redis-server *:17287\r\nroot@dockerdemo:~/moby#\r\n```\r\n\r\nThe redis's port in container redisps1 is 17287, which is just equals to st's pid in container redisps.\r\nThen run this command:\r\n```\r\nroot@dockerdemo:~/moby# docker top redisps -C st -o cmd,user,pid,%cpu\r\nCMD                 USER                PID                 %CPU\r\n/bin/bash           /st                 17287               root 17407 0.0\r\nroot@dockerdemo:~/moby# cd /opt/runctest/redis/\r\n```\r\nThe PID 17407 belongs to container redisps1, not redisps. If I kill this pid, something will wrong.\r\n\r\n**- Description for the changelog**\r\nIn most situations, ps -q can work.\r\nsuch as: ps -ef -q <pids> will return success result.\r\nFor some parameters can't work with -q, I think we should not retry without -q, because it is very dangerous.\r\n\r\n\r\n**- A picture of a cute animal (not mandatory but encouraged)**\r\n![xiongmao](https://user-images.githubusercontent.com/783424/44954717-fc11e400-aed8-11e8-95f2-67f06672a97b.jpg)\r\n"},"comment":{"url":"https://api.github.com/repos/moby/moby/issues/comments/420795643","html_url":"https://github.com/moby/moby/pull/37748#issuecomment-420795643","issue_url":"https://api.github.com/repos/moby/moby/issues/37748","id":420795643,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMDc5NTY0Mw==","user":{"login":"kolyshkin","id":4522509,"node_id":"MDQ6VXNlcjQ1MjI1MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/4522509?v=4","gravatar_id":"","url":"https://api.github.com/users/kolyshkin","html_url":"https://github.com/kolyshkin","followers_url":"https://api.github.com/users/kolyshkin/followers","following_url":"https://api.github.com/users/kolyshkin/following{/other_user}","gists_url":"https://api.github.com/users/kolyshkin/gists{/gist_id}","starred_url":"https://api.github.com/users/kolyshkin/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kolyshkin/subscriptions","organizations_url":"https://api.github.com/users/kolyshkin/orgs","repos_url":"https://api.github.com/users/kolyshkin/repos","events_url":"https://api.github.com/users/kolyshkin/events{/privacy}","received_events_url":"https://api.github.com/users/kolyshkin/received_events","type":"User","site_admin":false},"created_at":"2018-09-12T20:59:11Z","updated_at":"2018-09-12T20:59:11Z","author_association":"CONTRIBUTOR","body":"@lifubang can you please update my integration test? It appears you're using an old version.\r\n\r\nAlso, we can remove `validatePSArgs` since we have added PID field ourselves. I think it would be good to check that if the boolean is set, the first field is indeed \"PID\"."}}
{"actor":{"display_login":"kolyshkin"}}