kovidgoyal / kitty

Cross-platform, fast, feature-rich, GPU based terminal
https://sw.kovidgoyal.net/kitty/
GNU General Public License v3.0
24.15k stars 972 forks source link

kitty +kitten icat /path/to/image.png in a Docker container #5809

Closed jamilraichouni closed 1 year ago

jamilraichouni commented 1 year ago

Hi!

After nearly one day of trying hard, googling, searching the kitty homepage, searching the repo here and many try and error runs I kindly ask for a hot tip what I miss.

I have an Archlinux Docker container and cannot get above command

kitty +kitten icat /path/to/image.png to work.

I get the message Terminal does not support reporting screen sizes via the TIOCGWINSZ ioctl

The host is on macOS Monterey 12.6.2 My environment in the container:

$ env | grep -iP '(kitty|term)'
TERM=xterm-kitty
TERMINFO=/usr/share/terminfo

On the macOS host and in the Archlinux container I get:

$ kitty --version
kitty 0.26.5 created by Kovid Goyal

Is there any clever config to set up so that I can use that fantastic kitten in a running devcontainer?

Maybe some bind volume for a socket between the host kitty and the container kitty?

Potentially of interest is that I also tried the SYS_TTY_CONFIG capability one can configure when running a container:

docker run --rm -it --cap-add=ALL --privileged my_image_name zsh

see also here: https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities

image

Many thanks and all best, Jamil

kovidgoyal commented 1 year ago

I assume you are using some multiplexer like tmux, or something else that sits between icat and the real terminal and intercepts escape codes. Just ssh into your container and icat will work fine.

page-down commented 1 year ago

... or something else that sits between icat and the real terminal ...

That would be the Docker CLI (client).

I believe this is not supported in docker, currently. The problem with getting screen rows and columns has only been fixed in a recent beta release of docker (in the test repo). However, ws_xpixel and ws_ypixel still return zero.

As kovid suggested, you can use ssh (and also kitty +kitten ssh).

jamilraichouni commented 1 year ago

I assume you are using some multiplexer like tmux, or something else that sits between icat and the real terminal and intercepts escape codes. Just ssh into your container and icat will work fine.

Nope, I directly execute a zsh in the container via the following command fired in kitty on the macOS host:

docker run --rm -it --cap-add=ALL --privileged my_image_name zsh

and in the container I also have a kitty install which raises the error I mentioned in the initial post.

jamilraichouni commented 1 year ago

... or something else that sits between icat and the real terminal ...

That would be the Docker CLI (client).

I believe this is not supported in docker, currently. The problem with getting screen rows and columns has only been fixed in a recent beta release of docker (in the test repo). However, ws_xpixel and ws_ypixel still return zero.

As kovid suggested, you can use ssh (and also kitty +kitten ssh).

Thank you! Will follow the Docker repo/ beta info and also try the ssh workaround these days.

jamilraichouni commented 1 year ago

As kovid suggested, you can use ssh (and also kitty +kitten ssh).

Thinking about that a second time, I conclude that this won't help.

The scenario:

There is kitty running on a physical host (Macbook in this case) and the startup_session of kitty ensures that the container will be running and let's the first tab directly land in a zsh session in an Archlinux devcontainer.

From then onwards really everything takes place in the container. There is nvim plus stuff needed (all dev tools like language servers, vifm and much more) containerised.

The requirement:

Have kitty in the container installed and be able to use it to display images.

Conclusion:

This seems to be not possible right now since the icat kitten in the container gets no sizes for the kitty OS window running on the host.

My hope was that I can get the both kittys (host and container) to somewhat speak to each other so that the kitty in the container might get the terminal size from the kitty running on the host showing the OS window I'm looking at.

The ssh thing (installing an ssh server in the container and connecting from the host to it) won't come with any benefit here. It is easier to just mount host dirs into the container and then deal with shared volumes and run the icat kitten on the host. At the same time this is inconvenient since the terminal sessions (e. g. cwd) on the host and in the container are completely decoupled.

I wish you a Merry Christmas, Jamil

jamilraichouni commented 11 months ago

... or something else that sits between icat and the real terminal ...

That would be the Docker CLI (client).

I believe this is not supported in docker, currently. The problem with getting screen rows and columns has only been fixed in a recent beta release of docker (in the test repo). However, ws_xpixel and ws_ypixel still return zero.

As kovid suggested, you can use ssh (and also kitty +kitten ssh).

This works :-) Didn't get the point (kitty +kitten ssh into running [sshd] container instead of docker exec) .

Thank you!