11. REST LIKE API
The API tends to be REST, but for some
complex commands, like attach or pull, the
HTTP connection is hijacked to transport
STDOUT, STDIN, and STDERR.
13. FOR EXAMPLE
List containers
Create a container
Start a container
Stop a container
Remove a container
List Images
Build image from a Dockerfile
Create an image
Display system-wide information
Show the docker version information
...
14. REQUIREMENTS
needs some settings for access control
$DOCKER_OPTS in /etc/init/docker.conf on Ubuntu
$OPTIONS in /etc/sysconfig/docker on other Linux
if 192.0.2.1 is a client,
DOCKER_OPTS="-H 192.0.2.1:2376 -H unix:///var/run/docker.sock"
OPTIONS="-H 192.0.2.1:2376 -H unix:///var/run/docker.sock"
https://docs.docker.com/engine/userguide/basics/#bind-
docker-to-another-host-port-or-a-unix-socket
15. NOTE
make sure to hear from unix domain socket.
OPTIONS="-H 192.0.2.1:2376 -H unix:///var/run/docker.sock"
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
or, docker commands are not available.
16. FOR DOCKER MACHINE
machines created by docker-machine needs https
by default, in your ~/.docker/machine/machines/(machine
name)/
cert.pem
key.pem
this path is set by "$(docker-machine env (machine name))"
as $DOCKER_CERT_PATH
17. INFO
wget http://(machine ip):2376/info -O - -q | jq .
for docker-machine
wget
--no-check-certificate
--certificate=${DOCKER_CERT_PATH}/cert.pem
--private-key=${DOCKER_CERT_PATH}/key.pem
https://$(docker-machine ip (machine name)):2376/info
-O - -q | jq .
"curl" can't handle non-checking local cert, so use "wget"
18.
19. STATS API
to get container's metrics, use stats API
GET /containers/(id)/stats
https://docs.docker.com/engine/reference/api/docker_remote_
container-stats-based-on-resource-usage
24. SCHEMALESS
there is no need to define somethings
when writing data, InfluxDB needs only
TABLE NAME and VALUE
these are optional
timestamp
tags
https://influxdb.com/docs/v0.9/concepts/schema_and_data_la
25. SQL LIKE QUERY
to read
SELECT * FROM cpu_load_short WHERE host=server01 AND region=us-west
-- ^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-- table name tags
https://influxdb.com/docs/v0.9/query_language/data_explor
29. METRICS COLLECTOR
get metrics from Docker remote API and insert them
InfluxDB
in Ruby
requires gem "clockwork"
runs a collection minutely
30. VISUALIZE
in HTML and JavaScript
use chart.js
use some EcmaScript 2015 features
"let" statement
Promise
Object.assign
http://www.chartjs.org/
now available with only Google Chrome
34. PROBLEMS
load
stats API is heavy
pull architecture
calling API is proportional to number of containers
handling mass containers
id is not human-friendly
35. PUSH ARCHITECTURE AND AGENT
to collect with low load, we need inspect /sys
cat /sys/fs/cgroup/memory/docker/<container-id>/memory.stat
cat /sys/fs/cgroup/cpuacct/docker/<container-id>/cpuacct.stat
pull architecture is unfit to cat local files
agent is needed
https://docs.docker.com/engine/articles/runmetrics/