How to open local terminal when running VSCode in a Dev Container

Viewed 907

I'm writing code with VSCode from inside a VSCode container.

I can open terminals inside the dev container, but I can't figure out how to open a (VSCode integrated) terminal in my local machine.

I can of course open a separate terminal application like iTerm2, but it's far more convenient to use VSCode's integrated terminal panel. Is opening a local terminal possible with VSCode dev containers?

1 Answers

Provided that you have key-based SSH access from the container to the host, you can add a terminal profile to your remote settings (run command Preferences: Open Remote Settings (JSON) (Dev Container) to open them):

{
    "terminal.integrated.profiles.linux": {
        "bash (Host)": {
            "path": "ssh",
            "icon": "terminal-bash",
            "args": [
                "user@host",
            ],
        },
    },
}

This will get you an according bash (Host) entry in your "Add Terminal" drop-down menu:

enter image description here

Related