What is DevTable? DevTable is a browser-based, hosted, collaborative IDE Develop in the cloud with the same power as your desktop applications
Debug and Test
Deploy ● Google App Engine ● REST ● SCP ● Git (Heroku and other providers)
Sealed evil in a can There are a lot of neat things that we run for our users, but they are all potentially very dangerous: ● App Engine Development Server ● Debuggers and Emulators ● REPLs (Python, etc) ● Terminal support (which means all of the above as well)
Why this is a problem ● Without a containment system of some kind, any of these awesome features would allow users to cause mayhem: ○ A REPL use could open any file ○ A DevServer can execute arbitrary code ○ A terminal could al ow anything to happen
Why not simply use permissions? ● Permissions solve the file access problem ● Permissions do not prevent users from causing other system issues: instability, exhaustion, escalation, etc
Solution: containers! To contain the insecurity of running live code, we run all non-custom code in a container, with only the user’s project mounted and available Project data Evil (not to scale) Container
Ideal container properties ● Lightweight ● Secure ● Easy to manage ● FAST
Originally we used LXC... ● Lightweight (sort of…) ● Secure ● Easy to manage (sort of...) ● FAST
In the beginning, there was LXC... … and it was slow. ● Typical startup times for our containers were on the order of minutes ● Starting a debugger or shell is not fun at those speeds ● Getting the security and management just right was quite painful
Then the community said “let there be Docker”... Yo!
… and it made things amazing. Our average startup time for a container has dropped from over a minute to just under four seconds. LXC Go make a cup of coffee and play swords on office chairs Docker Go!
But, but Docker is just... LXC... Almost, Docker does some things that make starting up single processes lightning quick: ● Incremental by default ● Replace distro init process with lightweight version ● No DHCP, upstart, dnsmasq, etc. ● Aufs seems to be faster than OverlayFS ● Build process is MUCH better (Dockerfiles)
Docker at DevTable The fun technical details!
DevTable overview Clients WebSocket Clients - Socket Clients - W Fr eb ontends W B eb ackends Web browsers browsers browsers Python C# Thrift HTTP ? Clients - Images Container Web Servers browsers DFS Python SSH
Things we’ll discuss today Clients WebSocket Clients - Socket Clients - W Fr eb ontends W B eb ackends Web browsers browsers browsers Python C# Thrift HTTP ? Clients - Images Container Web Servers browsers DFS Python SSH
How we use docker now ● Python Docker API bindings ● Run a single instance per project ● Mount only the files relevant to the project in the container ● Run an SSH “command and control” process ● Execute user processes through SSH ● Dynamic version of Docker port forwarding
Backend <-> Container server Backends C# Thrift Container Servers Python
Container server The container server is the server in charge of managing all aspects related to the Docker containers ● Written in Python ● Conforms to a Thrift interface ● Called by the Backends to start containers, stop containers, run commands, mount file systems in containers, etc
Container server startContainer Starts a new container for a project. runCommand Runs a command inside a container stopCommand Stops a command inside a container notifyFilesModifed Notifies a container that a file has been modified by the backend stopContainer Stops a container
Handling file changes ● Changes made by the container or the backend to the DFS are propagated automatically ● However, both sides have code that depends on notification of changes ● Each server notifies the other about changes that occur via a notification service
DFS change notifications Container Hey, a user added file “test.txt” in container 1234 Backend Server C# Python Container Hey, the user changed file “foo.py” in container 1 Backend Server C# Python
How we handle file changes in Docker ● The container server watches changes inside the container using inotify, and reports changes to the backend ● The backend reports changes to the container server which will touch files that have been added or changed
Container server <-> Docker SSH Clients - Container Web Servers browsers Python
Container server <-> Docker We use the Python Docker bindings to create a new image and load it with a temporary ssh key New container requests bring up the container with the known session SSH key and issue commands to the container via SSH Much better than LXC issuing commands via subprocess
Docker <-> Outside world For many services we run (such as the App Engine Development Server), we need to expose the server running inside Docker to the outside world
Docker <-> Outside world Clients HTTP Web browsers Container Server HAProxy HTTP
Docker <-> Outside world Services inside of Docker as exposed via dynamic port mapping to a HAProxy running on the container server The HAProxy exposes the port by remapping it to the external port and a custom subdomain
Docker <-> Outside world Clients 93nx83ndsc34mn.c4.devtable.io:80 Web browsers Container Server HAProxy Port 38563
Example: running a dev server 1. Backend requests a container from the server I need a container for project “testapplication” Container Backend Server C# Container “container1234” started for project Python
Example: running a dev server 2. Backend registers for file notification events Let me know if any files change Container Backend Server C# Duly noted Python
Example: running a dev server 3. Backend asks for the dev server to be started and port 80 to be forwarded Please start the dev server and forward port 80 Container Backend Server Dev server started and port is forwarded at C# subdomain foobarbaz Python
Example: running a dev server 1. Container server tells Docker to start a container create_container, mount_filesystem, forward_port, start_ssh Container Server Python Done. Port exposed: 84639
Example: running a dev server 2. Container server tells HAProxy to forward the port returned by docker Forward port 84639 as subdomain foobarbaz Container Server HAProxy Python
Example: running a dev server 3. Container server tells Docker to run the dev server ssh command_for_devserver Container Server Python
Summary Docker has allowed DevTable to run amazing tools securely and fast, without a large management overhead
Future opportunities Docker presents some amazing new opportunities for DevTable and the community: ● Ability to quickly load (and save) complete development environments, securely ● Ability to quickly write custom plugins and run them in our IDE (want to analyze and build Go? just give us a URL or a Dockerfile!)
But wait… There’s something that has been bugging us… How should we distribute our private images in production?
Quay Demo At this point in the live talk we unveiled and gave a demo of our hosted private docker registry called Quay.io.
Questions? Comments? Witty anecdotes? devtable.com Jacob Moshenko - email@example.com Joseph Schorr - firstname.lastname@example.org