LoginSignup
6
6

More than 1 year has passed since last update.

Linux上のsingularityコンテナにWindowsのvscodeから接続する

Last updated at Posted at 2022-04-07

はじめに

WindowsのVSCodeから「Remote – SSH」の拡張機能を使って、Linux環境にSSH接続し、デバッグはできていた。
しかし、Linux上でSingularityを用いて複数の環境を使い分けした場合に、Linux環境に直接接続するのではコンテナイメージの環境でデバッグできず、不便であった。
そこでLinux上のSingularityコンテナにWindowsのvscodeから接続する方法について調べてみた。

参考元:
https://github.com/microsoft/vscode-remote-release/issues/3066#issuecomment-1019500216

環境

Windows
 VSCode 1.65.2(1.64以上)
  └Remote - SSH v0.76.1

Linux
 ubuntu 18.04
 singurality 3.9.2

ssh接続のためのconfigファイル

config
Host [ホスト名]-[コンテナイメージ名]
  HostName [ホスト名]
  User [ユーザ名]
  RemoteCommand singularity shell [singularityイメージファイル]
  RequestTTY yes
  • Host[ホスト名]-[コンテナイメージ名]と設定しているのは明示的にするため。任意でよい。
  • configファイルはC:\Users\[Windowsユーザ名]\.ssh\にあるのが一般的。
  • VSCodeでRemoteCommandを使えるようになったのが1.64からみたい。

settings.jsonファイル

settings.json
{
"-------------------[中略]-------------------"
    "remote.SSH.serverInstallPath": {
        "[ホスト名]-[コンテナイメージ名]": "~/.vscode-container/[ホスト名]-[コンテナイメージ名]"
    },
    "remote.SSH.enableRemoteCommand": true,
    "remote.SSH.useLocalServer": true,
"-------------------[中略]-------------------"
}
  • 接続先に拡張機能をインストールする際、remote.SSH.serverInstallPathを設定しておくことで、その接続先にだけインストールすることができるようになるみたい?(他環境を汚さないためなのかな)

VSCodeからSSH接続

  • 左下の $ _>^< $ をクリック
    image.png

  • Connect to Host...を選択
    image.png

  • [ホスト名]-[コンテナイメージ名]を選択
    image.png

  • 任意でパスワードを入力

  • ubuntu内に用意したコンテナ内に接続できた
    image.png

VSCodeでデバッグできた

image.png

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6