{"id":16730424,"url":"https://github.com/oschulz/container-env","last_synced_at":"2025-03-21T21:31:15.031Z","repository":{"id":38358809,"uuid":"105989743","full_name":"oschulz/container-env","owner":"oschulz","description":"Virtual container environments with Singularity or Shifter","archived":false,"fork":false,"pushed_at":"2024-12-13T10:07:04.000Z","size":34,"stargazers_count":10,"open_issues_count":2,"forks_count":8,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-18T05:22:58.395Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/oschulz.png","metadata":{"files":{"readme":"README-VSCode.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-10-06T09:52:26.000Z","updated_at":"2024-12-13T10:07:08.000Z","dependencies_parsed_at":"2023-11-28T17:29:20.368Z","dependency_job_id":"ea2c82ab-9a14-4e5b-b439-b2da079c7b2b","html_url":"https://github.com/oschulz/container-env","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oschulz%2Fcontainer-env","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oschulz%2Fcontainer-env/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oschulz%2Fcontainer-env/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/oschulz%2Fcontainer-env/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/oschulz","download_url":"https://codeload.github.com/oschulz/container-env/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244874161,"owners_count":20524576,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-12T23:33:25.258Z","updated_at":"2025-03-21T21:31:15.017Z","avatar_url":"https://github.com/oschulz.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Using cenv with Visual Studio Code\n\nHere's how to do remote development *inside* of a `cenv` container instances, using [Visual Studio Code](https://code.visualstudio.com/) on your local machine. This will make the remote VS-Code server instance at on the remote system(s) run inside the the container instance, so the container's file system will be fully visible to VS-Code.\n\nVS code [doesn't natively support](https://github.com/microsoft/vscode-remote-release/issues/3066) non-Docker-like container runtimes yet, the workaround described below works well in practice though. The procedure is a bit involved, but the result is worth the effort.\n\nNote: An alternative could be to use [Visual Studio Code Tunnels](https://code.visualstudio.com/docs/remote/tunnels), by starting the VS-Code server inside of a `cenv` instance. It may not be possible to run multiple VS-Code server instances in different `cenv` environments on one machine in parallel, though. The procedure described below uses VS-Code SSH instead of VS-Code Tunnels and *does* support parallel remote VS-code sessions in different `cenv` environments on the same remote machine.\n\n\n### Step 1\n\nEnsure that `cenv` is installed as `~/.local/bin/cenv` (directly or via symlink) on the remote system.\n\n\n### Step 2\n\nIn your `\"$HOME/.ssh/config\"` on your *local system*, add something like\n\n```\nHost mycenv~*\n  RemoteCommand ~/.local/bin/cenv mycenv\n  RequestTTY yes\n\nHost othercenv~*\n  RemoteCommand ~/.local/bin/cenv othercenv\n  RequestTTY yes\n\nHost somehost mycenv~somehost othercenv~somehost\n  HostName somehost.some.where\n\nHost somehost mycenv~somehost othercenv~somehost\n  HostName somehost.some.where\n```\n\nTest whether this works by running `ssh mycenv~somehost` *on your local system*. This should drop you into an SSH\nsession running inside of an instance of the `mycenv` cenv-environment on host \"somehost.some.where\"\n\n\n### Step 3\n\nIn your VS-Code settings *on your local system*, set\n\n```\n\"remote.SSH.enableRemoteCommand\": true\n```\n\n### Step 4 (Shifter-only)\n\nThis step is optional if you use Apptainer, it is only required with Shifter as the container runtime.\n\nSince VS-Code reuses remote server instances, the above is not sufficient to run multiple container images on the same\nremote host at the same time. To get *separate* (per container image) VS-Code server instances on the *same host*, add\nsomething like this to your VS-Code settings *on your local system*:\n\n```json\n\"remote.SSH.serverInstallPath\": {\n  \"mycenv~somehost\": \"/user\",\n  \"mycenv~otherhost\": \"/user\",\n  \"othercenv~somehost\": \"/user\",\n  \"othercenv~otherhost\": \"/user\"\n}\n```\n\nThis will force VS-Code to install it's server component into `/user/.vscode-server`.\n\nWhen using Apptainer, cenv will automatically try to bind-mount `/user/.vscode-server` to `$HOME/.vscode-server`, so\nsetting `remote.SSH.serverInstallPath` in VS-Code is not required.\n\n\n### Step 5\n\nConnect to `somehost` from with VS-Code *running your local system*:\n\n`F1 \u003e \"Connect to Host\" \u003e \"mycenv~somehost”` should now start a remote VS-Code session with the VS-Code server\ncomponent running inside a cenv container instance on `somehost`. The same for `\"othercenv~somehost\"`,\n`\"mycenv~otherhost\"` and `\"othercenv~otherhost\"`.\n\n\n### Tips 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\nexternal terminal, kill the remote VS-Code server instance (and everything else):\n\n```shell\nssh somehost\npkill -9 node\n```\n\n(This will kill *all* Node.jl processes you own on the remote host.)\n\nRemove the ~/.vscode-server directory in your home directory on the remote system.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foschulz%2Fcontainer-env","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foschulz%2Fcontainer-env","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foschulz%2Fcontainer-env/lists"}