“Docker allows you to package an applicaXon with all
of its dependencies into a standardized unit for
so`ware development.”
host linux system
container process
process
virtual file system
system namespaces
docker daemon/API tools
container process
process
virtual file system
system namespaces
…
process virtualiza/on
not your parent’s virtualization
• it’s lightweight!
• process containers measured in terms of kilobytes or megabytes
instead of GB
• startup measured in seconds, not minutes
• images are layered and reusable
• (see DockerHub)
• there’s powerful introspecXon / management APIs
• Management is programmable
codetainer architecture
codetainer
API server
loaded via
iframe
docker
API
“codetainer”
process
“codetainer”
process
“codetainer”
process
http /
websockets
sqlite
/api/v1/codetainer/{id}/attach
/api/v1/codetainer/{id}/create
/api/v1/codetainer/{id}/stop
…
components
• “codetainer”
• this is just a Docker container
• “codetainer image”
• this is a Docker image registered for codetainer use
• “codetainer profile”
• this is a profile associated with a codetainer that
defines its runXme characterisXcs (e.g. security)
other tools
• Go
• Docker APIs wrifen in this
• It’s just a nice, clean language you can be producXve in quickly
• xterm.js
• for rendering terminals in the browser
• sqlite
• for storing metdata about ‘codetainers’
step 3: interact with it!
• /api/v1/codetainer/{id}/attach
(attach
via
websockets)
• /api/v1/codetainer/{id}/view
(render
terminal
view)
• /api/v1/codetainer/{id}/send
(send
keystrokes)
more!
• List/Upload/Download files in a codetainer
• GET
/api/v1/codetainer/{id}/files
• GET
/api/v1/codetainer/{id}/files/
download
• PUT
/api/v1/codetainer/{id}/files/upload
command-line too
$
./bin/codetainer
list
Found
2
codetainers.
-‐-‐
[4505c3c844a46f4966280cd6762d3512ba8c04ebd5cb550ba90732c11a5514ee]
lRf9QWOrhAYbNf4_PUdZ58DtKpfmTihu
(Running)
-‐-‐
[c2fce38a8ba86caf0e3f1462177809f14d905c26e3cd04ac907d7d18ad9a63f0]
R0bZK2O-‐1SWsoTp7a2gas1-‐cHjnFIlf_
(Running)
$
./bin/codetainer
image
register
ubuntu:14.04
Codetainer
08:01:31
[~INFO]
Registering
New
Image:
&{91e54dfb11794fad694460162bf0cb0a4fa710cfa3f60979c177d920813e
267c
[ubuntu:14.04]
0001-‐01-‐01
00:00:00
+0000
UTC
0001-‐01-‐01
00:00:00
+0000
UTC
true}
odetainer
08:01:31
[~INFO]
Registration
succeeded.
challenges
Dealing with missing introspecXon APIs (e.g. file lisXng)
minimize risk of abuse by ‘sandboxing’ what a
container can do
{
"Config":
{
"NetworkDisabled":
true
},
"HostConfig":
{
"Privileged":
false,
"ReadonlyRootfs":
true,
"Memory":
1000000000,
"Ulimits":
[{
"Name":
"nofile",
"Soft":
1024,
"Hard":
2048
}]
}
limiting a codetainer’s permissions using
profiles
$
./bin/codetainer
profile
register
./
secure.json
secure
2015/09/18
10:52:54
Created
profile
with
id=767653c7-‐8fb6-‐4f78-‐bfcf-‐3853bbe6df64:
2015/09/18
10:52:54
-‐-‐
2015/09/18
10:52:54
{
"Config":
{
"NetworkDisabled":
true
},
"HostConfig":
{
• pass
codetainer-‐profile-‐id
to
POST
/api/v1/
codetainer
when
creating
a
codetainer
secure.json
Missing APIs
• Docker has an API to ‘exec’ processes in the context
of a container.
• SoluXon: mount all codetainers with a shared “/
codetainer/uXls” volume with custom tools.
• Example: /api/v1/codetainer/{id}/files
• Executes /codetainer/uXls/files —path <path>
• returns JSON path lisXng
status
• “Alpha” -‐ works but needs a lifle more ‘umph’ to
make it producXon ready
• Auth for API
• DocumentaXon, documentaXon, documentaiton
• TesXng