GithubHelp home page GithubHelp logo

eliot-akira / docker-browser-console Goto Github PK

View Code? Open in Web Editor NEW

This project forked from max-mapper/docker-browser-console

0.0 3.0 0.0 117 KB

Forward input/output from docker containers to your browser

License: MIT License

docker-browser-console's Introduction

docker-browser-console

Forward input/output from docker containers to your browser

npm install docker-browser-console

To quickly try out a demo clone this repo and

npm install
npm run demo

Browser usage

First browserify the following code to bundle.js to create a terminal in your browser

var docker = require('docker-browser-console')
var websocket = require('websocket-stream')

// create a stream for any docker image
var terminal = docker() // use docker({style:false}) to disable default styling

// connect to a docker-browser-console server
terminal.pipe(websocket('ws://localhost:10000')).pipe(terminal)

// append the terminal to a DOM element
terminal.appendTo(document.body)

You can add that to an index.html page by doing

<!DOCTYPE html>
<html>
<body>
  <script src="bundle.js">
</body>
</html>

Server usage

Then create a server that will host our docker containers

var ws = require('ws')
var websocket = require('websocket-stream')
var docker = require('docker-browser-console')

var server = new ws.WebSocketServer({port:10000})

server.on('connection', function(socket) {
  socket = websocket(socket)
  // this will spawn the container and forward the output to the browser
  socket.pipe(docker('mafintosh/dev')).pipe(socket)
})

Now simply run the server and open index.html in your browser. You should be able to see a terminal running my dev image

License

MIT

docker-browser-console's People

Contributors

mafintosh avatar

Watchers

James Cloos avatar 3λiȯ+ avatar  avatar

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.