Connect your containers via a web-tty
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

Container web TTY

Go Report Card Master Build Status GoDoc license Docker Pulls MicroBadger Size GitHub release Github All Releases

中文

Tired of typing docker ps | grep xxx && docker exec -ti xxxx sh ? Try me!

Although I like terminal, I still want a better tool to get into the containers to do some debugging or checking. So I build this container-web-tty. It can help you get into the container and execute commands via a web-tty, based on yudai/gotty with some changes.

Both docker and kubectl are supported.

Usage

Of cause you can run it by downloading the binary, but thare are some Copy-and-Paste ways.

Using docker

You can start container-web-tty inside a container by mounting docker.sock:

docker run --rm -ti --name web-tty \
    -p 8080:8080 \
    -v /var/run/docker.sock:/var/run/docker.sock \
    wrfly/container-web-tty

Using kubernetes

Or you can mount the kubernetes config file:

docker run --rm -ti --name web-tty \
    -p 8080:8080 \
    -e WEB_TTY_BACKEND=kube \
    -e WEB_TTY_KUBE_CONFIG=/kube.config \
    -v ~/.kube/config:/kube.config \
    wrfly/container-web-tty

Using local <-> remote (gRPC)

You can deploy container-web-tty in remote servers, and connect to it via a local container-web-tty. They use gRPC for communication.

This is useful when you cannot get the remote servers or there are more than one server that you need to connect to.

Remote

Host 192.168.66.1 and 192.168.66.2 both running:

docker run --rm -ti --name web-tty \
    -p 8080:8080 \
    -p 8090:8090 \
    -e WEB_TTY_GRPC_PORT=8090 \
    -e WEB_TTY_GRPC_AUTH=96ssW0rd \
    -v /var/run/docker.sock:/var/run/docker.sock \
    wrfly/container-web-tty

Notes:

  • You can disable the HTTP server by setting WEB_TTY_PORT=-1
  • The WEB_TTY_GRPC_AUTH must be the same between all hosts

Local

docker run --rm -ti --name web-tty \
    -p 8080:8080 \
    -e WEB_TTY_BACKEND=grpc \
    -e WEB_TTY_GRPC_AUTH=96ssW0rd \
    -e WEB_TTY_GRPC_SERVERS=192.168.66.1:8090,192.168.66.2:8090 \
    wrfly/container-web-tty

Now you will see all the containers of all the servers via http://localhost:8080

Keyboard Shortcuts (Linux)

  • Cut the word before the cursor Ctrl+w => You cannot do it for now (I'll working on it for Ctrl+Backspace, but I know little about js)
  • Copy: Ctrl+Shift+c => Ctrl+Insert
  • Paste: Ctrl+Shift+v => Shift+Insert

Features

  • it works
  • docker backend
  • kubectl backend
  • beautiful index
  • start|stop|restart container(docker backend only)
  • environment injection (extra params)
  • proxy mode (client -> server's containers)
  • auth(only in proxy mode)
  • TTY timeout (idle timeout)
  • history audit (just cat the history logs after enable this feature)
  • real time sharing (like screen sharing)
  • container logs (just click the container name)
  • exec arguments (append an extra "?cmd=xxx" argument to exec URL)

Audit exec history and container outputs

docker run --rm -ti --name web-tty \
    -p 8080:8080 \
    -e WEB_TTY_AUDIT=true \
    -v `pwd`/container-logs:/log \
    -v /var/run/docker.sock:/var/run/docker.sock \
    wrfly/container-web-tty

After you exec some commands, you will see the inputs and outputs under the container-logs directory, you can use cat or tail -f to see the changes.

Real-time sharing

docker run --rm -ti --name web-tty \
    -p 8080:8080 \
    -e WEB_TTY_SHARE=true \
    -v /var/run/docker.sock:/var/run/docker.sock \
    wrfly/container-web-tty

By enabling this feature, you can share the container's inputs and outputs with others via the share link (click the container's image to get the link).

Show-off

List the containers on your machine:

list

It will execute /bin/sh if there is no /bin/bash inside the container:

/bin/bash:

Run custom command:

Get container logs:

logs