Skip to content

Repository files navigation

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

vardocker=require('docker-browser-console')varwebsocket=require('websocket-stream')// create a stream for any docker image// use docker({style:false}) to disable default styling// all other options are forwarded to the term.js instancevarterminal=docker()// connect to a docker-browser-console serverterminal.pipe(websocket('ws://localhost:10000')).pipe(terminal)// append the terminal to a DOM elementterminal.appendTo(document.body)

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

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

Server usage

Then create a server that will host our docker containers

varws=require('ws')varwebsocket=require('websocket-stream')vardocker=require('docker-browser-console')varserver=newws.Server({port:10000})server.on('connection',function(socket){socket=websocket(socket)// this will spawn the container and forward the output to the browsersocket.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

About

Forward input/output from docker containers to your browser

Resources

Stars

88 stars

Watchers

9 watching

Forks

Releases

Packages

Used by

Contributors

Languages