mrjackwills / oxker

A simple tui to view & control docker containers
MIT License
694 stars 24 forks source link

[NEW FEATURE] Exec Shell - Open a container command line #28

Closed varaskkar closed 11 months ago

varaskkar commented 1 year ago

Hi, I discovered Oxker only a short time ago and I am delighted. I love how simple it is and its beautiful interface. So far I have been using ctop, it is not as nice but it has a feature that is a must for me which is "Exec Shell", that is, I can connect to the container through the console. The truth is that I would like to replace ctop by oxker for my daily use.

I would like to know if there are future plans to implement the connection to the container.

Screenshots: https://i.imgur.com/7wIpc14.jpg https://i.imgur.com/64L4EQw.jpg

mrjackwills commented 1 year ago

Thanks, yeah this is one of the features that I have on my wish list.

I am in the final stages of changing from tui-rs to ratatui, the latter of which sounds like it'll merge some new widgets, which should make user input a lot easier.

Would need to think about the best way to show all the information, as the output from a container could be multi-lined, or possibly difficult to convey in a small section of the oxker window. Although, ctop, when in exec shell mode, takes control of the whole terminal (disregarding the ctop ui)?

varaskkar commented 1 year ago

Ohh sounds great, you made my day! Besides, I didn't know ratatui so that's cool

In fact yes, ctop cleans all the ui taking the whole screen. Not a bad option although I don't know if it would fit with oxker's design 🤔...

ctop does one thing to display more information by pressing the left and right keys on a selected container. Left to show the log and Right to show cpu/ram/network,...it's as if it had 3 windows, the main one and 2 on the sides.

As an idea based on this, maybe a shell could be executed by pressing the right key or something similar.

Although another solution could be to press Enter when a container is selected, click on "exec shell" and split the log section in half... I'm not sure

mrjackwills commented 1 year ago

Sounds good, yeah I'll give it a think, as want to try to keep oxker as simple as possible.

I do quite like the ctop method of taking control of the whole terminal, could replicate something like that, although maybe keep a bar at the top, saying something like "You are currently in a shell of [container-name]".

I've just released v0.3.0 of oxker, so probably won't investigate this feature until the next time I spend some time on oxker, although I agree that it should have this ability.

varaskkar commented 1 year ago

Sure, and I was surprised how fast you released the new version 🎉 I'm gonna take a look at it.

maybe keep a bar at the top, saying something like "You are currently in a shell of [container-name]"

I like this idea so much! (ctop doesn't do this).

mrjackwills commented 1 year ago

I have a basic working version, see the feat/exec_tty branch, and specifically the exec.rs file, but I cannot get it to execute correctly.

Specifically, when exiting a container shell, a user needs to press an additional key press before oxker enters the correct state, but I am at a loss as to where this specific issue, possible a lock, comes from.

The feat/exec_tty branch at the moment shows a popup, telling the user to press 'c' twice, to resolve this issue, but obviously this is not in anyway a good solution. It also has lots of useless code, mainly drops, as I try to work out where the issue originates from.

There are other issues, and edge cases with container shells, that need to be fixed but they are all straight forward to resolve compared to this current quandary.

EDIT: I think ctop has the same behavior, at least on my local & remote systems. If you exit from an exec shell, when back on the main ctop screen the first button press is ignored. In which case, I don't know the best way to proceed