attach vscode 原理是什么?

图片.png

在 vscode 中安装了 docker 插件之后,发现有一个 attach vscode 的功能

打开之后,有点类似 ssh remote

但是用的并不是 ssh

这是什么原理

比如我试了一下 rabbitmq3-management

直接 docker exec -it rabbitmq3-management bash 后查看所有进程:

root@rabbitmq3-management-standalone:/# ps jfax
   PPID     PID    PGID     SID TTY        TPGID STAT   UID   TIME COMMAND
      0 1332518 1332518 1332518 pts/0    1332525 Ss       0   0:00 bash
1332518 1332525 1332525 1332518 pts/0    1332525 R+       0   0:00  \_ ps jfax
      0       1       1       1 ?             -1 Ss     999   0:05 /bin/sh /opt/rabbitmq/sbin/rabbitmq-server
      1      20       1       1 ?             -1 Sl     999 130:20 /usr/local/lib/erlang/erts-13.1/bin/beam.smp -W w -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -sbwt none -sbwtdcpu none -sbwtdio none -B i -- -root /usr/l
     20      26      26      26 ?             -1 Ss     999   0:12  \_ erl_child_setup 1048576
     26     133     133     133 ?             -1 Ss     999   0:03      \_ /usr/local/lib/erlang/erts-13.1/bin/inet_gethost 4
    133     134     133     133 ?             -1 S      999   0:04      |   \_ /usr/local/lib/erlang/erts-13.1/bin/inet_gethost 4
     26     137     137     137 ?             -1 Ss     999   1:09      \_ /bin/sh -s rabbit_disk_monitor
      1      82      81      81 ?             -1 S      999   0:37 /usr/local/lib/erlang/erts-13.1/bin/epmd -daemon

使用 attach vscode 进入容器后查看所有进程:

root@rabbitmq3-management-standalone:~# ps jfax
   PPID     PID    PGID     SID TTY        TPGID STAT   UID   TIME COMMAND
      0 1332871 1332871 1332871 ?             -1 Ssl      0   0:00 /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/node -e  ????const net = require('net'); ????const fs = require('fs'); ????process.stdin.pause(); ????const client = net.createConnect
      0 1332858 1332858 1332858 ?             -1 Ss       0   0:00 /bin/sh -c # Watch machine settings ???trap "exit 0" 15 ???old=`ls -A --full-time settings.json 2>/dev/null || true` ???counter=0 ???while [ $counter -lt 60 ] ???do ????sleep 1 ????new=`ls -A --full-time settings
1332858 1333161 1332858 1332858 ?             -1 S        0   0:00  \_ sleep 1
      0 1332813 1332813 1332813 ?             -1 Ssl      0   0:00 /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/node -e  ????const net = require('net'); ????const fs = require('fs'); ????process.stdin.pause(); ????const client = net.createConnect
      0 1332782 1332782 1332782 ?             -1 Ss       0   0:00 sh /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/bin/code-server --log debug --force-disable-user-env --server-data-dir /var/lib/rabbitmq/.vscode-server --telemetry-level all --acc
1332782 1332791 1332782 1332782 ?             -1 Sl       0   0:04  \_ /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/node /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/out/server-main.js --log debug --force-disable-
1332791 1332825 1332782 1332782 ?             -1 Sl       0   0:00      \_ /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/node /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/out/bootstrap-fork --type=ptyHost --logsPat
1332825 1333089 1333089 1333089 pts/0    1333166 Ss       0   0:01      |   \_ /bin/bash --init-file /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/out/vs/workbench/contrib/terminal/browser/media/shellIntegration-bash.sh
1333089 1333166 1333166 1333089 pts/0    1333166 R+       0   0:00      |       \_ ps jfax
1332791 1332887 1332782 1332782 ?             -1 Sl       0   0:01      \_ /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/node /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/out/bootstrap-fork --type=extensionHost --t
      0 1332693 1332693 1332693 ?             -1 Ss       0   0:00 /bin/sh
1332693 1332731 1332693 1332693 ?             -1 Sl       0   0:00  \_ /var/lib/rabbitmq/.vscode-server/bin/e2816fe719a4026ffa1ee0189dc89bdfdbafb164/node /tmp/vscode-remote-containers-server-1a8800744ee456e6c2768aea24ffa6947e33623b.js
      0 1332631 1332631 1332631 ?             -1 Ss       0   0:00 /bin/sh
      0       1       1       1 ?             -1 Ss     999   0:05 /bin/sh /opt/rabbitmq/sbin/rabbitmq-server
      1      20       1       1 ?             -1 Sl     999 130:21 /usr/local/lib/erlang/erts-13.1/bin/beam.smp -W w -MBas ageffcbf -MHas ageffcbf -MBlmbcs 512 -MHlmbcs 512 -MMmcs 30 -P 1048576 -t 5000000 -stbt db -zdbbl 128000 -sbwt none -sbwtdcpu none -sbwtdio none -B i -- -ro
     20      26      26      26 ?             -1 Ss     999   0:12  \_ erl_child_setup 1048576
     26     133     133     133 ?             -1 Ss     999   0:03      \_ /usr/local/lib/erlang/erts-13.1/bin/inet_gethost 4
    133     134     133     133 ?             -1 S      999   0:04      |   \_ /usr/local/lib/erlang/erts-13.1/bin/inet_gethost 4
     26     137     137     137 ?             -1 Ss     999   1:09      \_ /bin/sh -s rabbit_disk_monitor
      1      82      81      81 ?             -1 S      999   0:37 /usr/local/lib/erlang/erts-13.1/bin/epmd -daemon

可以看到多了很多 vscode 相关的进程,但是没有 ssh 相关的进程

什么原理?

阅读 1.4k
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
logo
Microsoft
子站问答
访问
宣传栏