使用 Visual Studio Code 远程启动 Singularity 容器

Vis*_*hnu 5 remote-access visual-studio visual-studio-code singularity-container

我知道您可以在 VSCode 中远程启动 docker 容器。是否可以对奇点容器做同样的事情?

isl*_*ods 5

更新:此问题的解决方案已由用户发布在同一问题(https://github.com/microsoft/vscode-remote-release/issues/3066#issuecomment-1019500216oschulz )中:

\n
As promised, here are some instructions on how to use Singularity with VS-Code Remote SSH via SSH RemoteCommand. The procedure described below makes VS-Code run it\xe2\x80\x99s remote server component inside a Singularity container instance (other runtimes like Shifter work too).\n\nAcknowledgement: Credit for a lot of this goes to @gipert, who refined my original approach (using a custom SSH script) when support for RemoteCommand became available in VS-Code recently\n\nStep 1\n\nUse VS-Code >= v1.64 (includes support for the SSH RemoteCommand setting). Install the Pre-Release version of the Remote SSH extension\n\nImportant: In the VS-Code settings, set "remote.SSH.enableRemoteCommand": true.\n\nStep 2\n\nIn your "$HOME/.ssh/config", add something like\n\nHost myimage1~*\n  RemoteCommand singularity shell /path/to/image1.sif\n  RequestTTY yes\n\nHost myimage2~*\n  RemoteCommand singularity shell /path/to/image2.sif\n  RequestTTY yes\n\nHost somehost myimage1~somehost myimage2~somehost\n  HostName some.host.somewhere\n  User your_username_\n\nHost otherhost myimage1~otherhost myimage2~otherhost\n  HostName some.otherhost.somewhere\n  User your_username_\nTest whether this works using ssh myimage1~somehost. This should drop you into an SSH session inside of an instance of the "/path/to/image1.sif" container image on some.host.somewhere.\n\nConnecting to the remote host with VS-Code: F1 > "Connect to Host" > "myimage1~somehost\xe2\x80\x9d should now get you a remote VS-Code session running in the container image as well. The same for "myimage2~somehost", "myimage1~otherhost" and "myimage2~otherhost".\n\nStep 3\n\nHowever, since VS-code reuses remote server instance, that\'s not sufficient to run multiple container images on the same host at the same time. To get separate (per container) VS-Code server instances the same host, add something like this to your VS-Code preferences:\n\n"remote.SSH.serverInstallPath": {\n  "myimage1~somehost": "~/.vscode-container/myimage1",\n  "myimage1~otherhost": "~/.vscode-container/myimage1",\n  "myimage2~somehost": "~/.vscode-container/myimage2",\n  "myimage2~otherhost": "~/.vscode-container/myimage2"\n}\nRequest to the VS-Code dev team\n\nCould "remote.SSH.serverInstallPath" be controlled via an environment variable? This would allow us to eliminate all these cumbersome "remote.SSH.serverInstallPath" preferences. The environment variable could be set by a container startup script on the remote side (like the one below) automatically, depending on the selected container image.\n\nOther Container runtimes\n\nTo use a different container runtime than Singularity (e.g. Shifter, Charliecloud, etc.), simply replace singularity shell /path/to/image1.sif by the appropriate command for your runtime.\n\nOn some systems (e.g. with Shifter at NERSC) you may also need to override $XDG_RUNTIME_DIR, since it\'s default location may not be writable from within a container instance. In such cases, it\'s best to use a custom container run-script like\n\n#!/bin/sh\nexport XDG_RUNTIME_DIR="${TMPDIR:-/tmp}/`whoami`/run"\nexec shifter --image="$1"\nSo in your SSH config, use\n\n  RemoteCommand /my/homedir/.local/bin/run_container image_name\nI maintain a little container start-script called cenv that handles $XDG_RUNTIME_DIR (and quite a bit more, including some default bind-mounts) automatically for both Singularity and Shifter (contributions welcome).\n\nTips and tricks\n\nIf things don\'t work, try "Kill server on remote" from VS-Code and reconnect.\n\nYou can also try starting over from scratch with brute force: Close the VS-Code remote connection. Then, from an external terminal, kill the remote VS-Code server instance:\n\n$ ssh somehost\n$ kill -9 -1\n(Will kill all processes you own on the remote host.)\n\nRemove the ~/.vscode-server directory.\n
Run Code Online (Sandbox Code Playgroud)\n

老的

\n

我相信这仍然不受支持。请参阅此问题:https://github.com/microsoft/vscode-remote-release/issues/3066,同一链接中还有一些潜在解决方法的想法。

\n