DEV Community

stackshare with me
stackshare with me

Posted on

Docker Container web tty

Docker Container-web-tty

Connect your containers via a web-tty

Have you ever tired of typing

If you like terminal, and still want a better tool to get into the containers to do some debugging or checking.

Usage

Using docker

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

docker run -dti --restart always --name container-web-tty \
    -p 8080:8080 \
    -v /var/run/docker.sock:/var/run/docker.sock \
    wrfly/container-web-tty


# tail logs
docker logs -f container-web-tty

Using Kubernetes

Or you can mount the Kubernetes config file:

docker run -dti --restart always --name container-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 is 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 -dti --restart always --name container-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 -dti --restart always --name container-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*

Audit exec history and container outputs

docker run -dti --restart always --name container-web-tty \
    -p 8080:8080 \
    -e WEB_TTY_AUDIT=true \
    -v `pwd`/container-audit:/audit \
    -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-audit directory, you can use cat or tail -f to see the changes.

Real-time sharing

docker run -dti --restart always --name container-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:

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

/bin/bash:

Run the custom command:

Get container logs:

Top comments (0)