Giter Site home page Giter Site logo

cswclui / docker-browser-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from maslick/docker-browser-server

0.0 1.0 0.0 175 KB

Spawn and expose docker containers over http and websockets

License: MIT License

JavaScript 99.92% HTML 0.08%

docker-browser-server's Introduction

docker-browser-server

Spawn and expose docker containers over http and websockets

npm install -g docker-browser-server

Running the above will expose a command line tool called docker-browser-server. To run the server do

docker-browser-server docker-image-name --port 8080

Make sure you pulled docker-image-name from a docker registry first. Running the above will start the server on port 8080

Visit http://localhost:8080 after to attach to a container using a web browser.

Spawn a new container

To spawn a new container create a websocket to the server and pipe it to a docker-browser-console instance

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

var container = docker()
var socket = websocket('ws://localhost:8080')

container.appendTo(document.body)

socket.pipe(container).pipe(socket)

A demo interface is available if you simply visit http://localhost:8080 after starting the server

Expose filesystem

If you run expose-fs inside your container the containers file system will be exposed using the following rest api

  • GET /files/{container}/{path} Get a file or directory listing
  • PUT /files/{container}/{path} Write a new file with the http body
  • POST /files/{container}/{path} Create a new directory

Expose a http server

When you spawn a new container a special env var called $HOST will be set to a http address. If you listen on port 80 inside the container all requests going to $HOST will be forwarded to this server.

Adventure time

Checkout maxogden/adventure-time for a complete client environment that integrates with docker-browser-server.

The easiest way to create your own workshop is creating a new Dockerfile and inheriting from the mafintosh/docker-browser-adventure image. This will setup expose-fs and install node among other things

FROM mafintosh/docker-adventure-time
RUN npm install -g your-workshop-stuff

Programmatic usage

var server = require('docker-browser-server')

var s = server('mafintosh/dev')

s.on('spawn', function(container) {
  console.log('spawned new container', container.id)
})

s.on('kill', function(container) {
  console.log('killed container', container.id)
})

s.listen(8080)

License

MIT

docker-browser-server's People

Contributors

mafintosh avatar

Watchers

 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.