Git Product home page Git Product logo

dockertty's Introduction

DockerTTY - Terminal over web for remote docker container

DockerTTY is a simple command line tool that provides terminal over web for remote docker container.

DockerTTY is based on the work of GoTTY v1.0.0, but with following features:

  • Provides terminal over web for remote docker container
  • Allow to run command in the container like docker exec -it ${containerId} sh
  • Do not leave legacy processes in container

Installation

If you have a Go language environment, you can install DockerTTY with the go get command.

$ go get github.com/supereagle/dockertty

Usage

Usage: dockertty [options] <command> [<arguments...>]

Running dockertty will start a web server. Open the URL with the specified container id on your web browser, DockerTTY will run docker exec -it ${containerId} sh, then you can run command on your terminal as if you are running them in the container.

By default, DockerTTY starts a web server at port 8080, and permits clients to write to the TTY.

Options

--address, -a                                                IP address to listen [$GOTTY_ADDRESS]
--port, -p "8080"                                            Port number to listen [$GOTTY_PORT]
--permit-write, -w                                           Permit clients to write to the TTY (BE CAREFUL) [$GOTTY_PERMIT_WRITE]
--credential, -c                                             Credential for Basic Authentication (ex: user:pass, default disabled) [$GOTTY_CREDENTIAL]
--random-url, -r                                             Add a random string to the URL [$GOTTY_RANDOM_URL]
--random-url-length "8"                                      Random URL length [$GOTTY_RANDOM_URL_LENGTH]
--tls, -t                                                    Enable TLS/SSL [$GOTTY_TLS]
--tls-crt "~/.gotty.crt"                                     TLS/SSL certificate file path [$GOTTY_TLS_CRT]
--tls-key "~/.gotty.key"                                     TLS/SSL key file path [$GOTTY_TLS_KEY]
--tls-ca-crt "~/.gotty.ca.crt"                               TLS/SSL CA certificate file for client certifications [$GOTTY_TLS_CA_CRT]
--index                                                      Custom index.html file [$GOTTY_INDEX]
--title-format "GoTTY - {{ .Command }} ({{ .Hostname }})"    Title format of browser window [$GOTTY_TITLE_FORMAT]
--reconnect                                                  Enable reconnection [$GOTTY_RECONNECT]
--reconnect-time "10"                                        Time to reconnect [$GOTTY_RECONNECT_TIME]
--timeout "0"                                                Timeout seconds for waiting a client (0 to disable) [$GOTTY_TIMEOUT]
--max-connection "0"                                         Set the maximum number of simultaneous connections (0 to disable)
--once                                                       Accept only one client and exit on disconnection [$GOTTY_ONCE]
--permit-arguments                                           Permit clients to send command line arguments in URL (e.g. http://example.com:8080/?arg=AAA&arg=BBB) [$GOTTY_PERMIT_ARGUMENTS]
--close-signal "1"                                           Signal sent to the command process when gotty close it (default: SIGHUP) [$GOTTY_CLOSE_SIGNAL]
--config "~/.gotty"                                          Config file path [$GOTTY_CONFIG]
--version, -v                                                print the version

For more detailed usage, please refer to GoTTY Usage.

Advanced Usage

To login and exec command in containers in Kubernetes cluster, DockerTTY can be deployed as an agent on every Kubernetes nodes through Daemonset.

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  labels:
    app: dockertty-agent
  name: dockertty-agent
spec:
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: dockertty-agent
    spec:
      restartPolicy: Always
      hostNetwork: true
      containers:
      - image: ${DOCKERTTY_AGENT_IMAGE}
        name: dockertty-agent
        resources:
          limits:
            cpu: 800m
            memory: 1Gi
          requests:
            cpu: 400m
            memory: 500Mi
        ports:
          - name: agent-port
            hostPort: 8080
            containerPort: 8080
        volumeMounts:
        - mountPath: /var/run/docker.sock
          name: dockersock
        - mountPath: /usr/bin/docker
          name: dockerclient
        - mountPath: /usr/lib64/libltdl.so.7
          name: libltdl
      volumes:
      - hostPath:
          path: /var/run/docker.sock
        name: dockersock
      - hostPath:
          path: /usr/bin/docker
        name: dockerclient
      - hostPath:
          path: /usr/lib64/libltdl.so.7.3.0
        name: libltdl

Clients

Web Browser

Open the URL like http://localhost:8080?containerId=c28 in web browser.

GoTTY Client

GoTTY Client is a terminal client for GoTTY. It can also be used as a terminal client for DockerTTY.

$ ./gotty-client http://localhost:8080?containerId=c28

Architecture

GoTTY uses hterm to run a JavaScript based terminal on web browsers. GoTTY itself provides a websocket server that simply relays output from the TTY to clients and receives input from clients and forwards it to the TTY. This hterm + websocket idea is inspired by Wetty.

License

The MIT License

dockertty's People

Contributors

artdevjs avatar blakejennings avatar dehorsley avatar freakhill avatar gitter-badger avatar guywithnose avatar jensenbox avatar mattn avatar moul avatar shingt avatar shoz avatar skeltoac avatar supereagle avatar tsl0922 avatar uovobw avatar xinsnake avatar yudai avatar zyfdegh avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

hackpanda

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.