Open Docker terminal from Terminal #6838

Closed
opened 2026-01-31 00:48:32 +00:00 by claunia · 3 comments
Owner

Originally created by @jmsnavarro on GitHub (Mar 12, 2020).

Open a Docker-hosted terminal directly using Windows Terminal

  • Possibility to add a terminal profile hosted in Docker as part of the Windows Terminal profiles.
  • This allows the user to instantly launch a terminal session hosted by Docker (provided that there is an already active container)

Proposed technical implementation details

"profiles":
    [
        {
            "guid": "{5743275e-4f2q-5b06-ad1e-a6969a402336}",
            "hidden": false,
            "name": "Ubuntu 18.04 LTS over Docker",
            "source": "Docker.Container.Ubuntu.trusted-twister",
            "fontFace" : "Cascadia Code",
            "fontSize" : 10,
            "acrylicOpacity" : 1,
            "useAcrylic" : false	
        },
Originally created by @jmsnavarro on GitHub (Mar 12, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Open a Docker-hosted terminal directly using Windows Terminal - Possibility to add a terminal profile hosted in Docker as part of the Windows Terminal profiles. - This allows the user to instantly launch a terminal session hosted by Docker (provided that there is an already active container) <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> # Proposed technical implementation details ``` "profiles": [ { "guid": "{5743275e-4f2q-5b06-ad1e-a6969a402336}", "hidden": false, "name": "Ubuntu 18.04 LTS over Docker", "source": "Docker.Container.Ubuntu.trusted-twister", "fontFace" : "Cascadia Code", "fontSize" : 10, "acrylicOpacity" : 1, "useAcrylic" : false }, ``` <!-- A clear and concise description of what you want to happen. -->
claunia added the Issue-FeatureNeeds-Tag-FixResolution-Won't-Fix labels 2026-01-31 00:48:32 +00:00
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 12, 2020):

You’d be better served by just adding a new profile whose commandline is “docker exec -t -i container /process". Even if terminal guessed what shell you wanted inside a random container, it wouldn’t be very reliable and people would hate the autogenerating profiles for each one 😄

You know your containers a lot better than we ever could!

@DHowett-MSFT commented on GitHub (Mar 12, 2020): You’d be better served by just adding a new profile whose commandline is “docker exec -t -i container /process". Even if terminal guessed what shell you wanted inside a random container, it wouldn’t be very reliable and people would hate the autogenerating profiles for each one :smile: You know your containers a lot better than we ever could!
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 12, 2020):

Thanks, however, for the request!

@DHowett-MSFT commented on GitHub (Mar 12, 2020): Thanks, however, for the request!
Author
Owner

@jnovick commented on GitHub (Oct 6, 2020):

@jmsnavarro I have a script in my Ubuntu WSL distro for generating these profiles. I created it as an experiment. I am not sure what the practical purpose of wanting these profiles is, but you could copy and edit this t accomplish what you want. If you do not have jq installed, you can install it via sudo apt-get install -y jq. This also relies on the fact that there are no comments in the settings.json since jq cannot handle them.

VALUE=$(docker ps --format '{{ json . }}' | jq '{"name": ("Docker " + .Names + " " + .Image), "guid": ("{0974efce-f787-4a0a-8468-"+.ID+"}"), "hidden": false, "commandline": ("docker exec -it " + .Names + " /bin/bash")}' | jq -s .)
cat /mnt/c/Users/Joshua/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json \
  | jq '.profiles.list=([.profiles.list[] | select(.name | contains("Docker") | not)] + '$VALUE')' \
  > /mnt/c/Users/Joshua/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json

Once https://github.com/microsoft/terminal/pull/7584/https://github.com/microsoft/terminal/pull/7632 is done, you could leave comments in place and just direct the first line into a file instead of a variable.

@jnovick commented on GitHub (Oct 6, 2020): @jmsnavarro I have a script in my Ubuntu WSL distro for generating these profiles. I created it as an experiment. I am not sure what the practical purpose of wanting these profiles is, but you could copy and edit this t accomplish what you want. If you do not have `jq` installed, you can install it via `sudo apt-get install -y jq`. This also relies on the fact that there are no comments in the `settings.json` since `jq` cannot handle them. ``` bash VALUE=$(docker ps --format '{{ json . }}' | jq '{"name": ("Docker " + .Names + " " + .Image), "guid": ("{0974efce-f787-4a0a-8468-"+.ID+"}"), "hidden": false, "commandline": ("docker exec -it " + .Names + " /bin/bash")}' | jq -s .) cat /mnt/c/Users/Joshua/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json \ | jq '.profiles.list=([.profiles.list[] | select(.name | contains("Docker") | not)] + '$VALUE')' \ > /mnt/c/Users/Joshua/AppData/Local/Packages/Microsoft.WindowsTerminalPreview_8wekyb3d8bbwe/LocalState/settings.json ``` Once <https://github.com/microsoft/terminal/pull/7584>/<https://github.com/microsoft/terminal/pull/7632> is done, you could leave comments in place and just direct the first line into a file instead of a variable.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#6838