Ubuntu16.04 Docker的CS模式详细介绍

时间:2021-09-25 03:34:46

ubuntu16.04 docker的cs模式

Ubuntu16.04 Docker的CS模式详细介绍

Ubuntu16.04 Docker的CS模式详细介绍

remote api

docker除了使用命令让用户通过客户端与docker的守护进行通信,也提供了remote api方式的通信接口

restful风格api

stdin,stdout,stderr

Ubuntu16.04 Docker的CS模式详细介绍

连接方式

使用socket方式进行连接,有下列三种方式

unix:///var/run/docker.sock
tcp://host:port
fd://socketfd

Ubuntu16.04 Docker的CS模式详细介绍

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
eggyer@ubuntu:/usr/local/dockerfile/df_test1$ docker version
client:
 version:   1.9.1
 api version: 1.21
 go version:  go1.4.3
 git commit:  a34a1d5
 built:    fri nov 20 17:56:04 utc 2015
 os/arch:   linux/amd64
 
server:
 version:   1.9.1
 api version: 1.21
 go version:  go1.4.3
 git commit:  a34a1d5
 built:    fri nov 20 17:56:04 utc 2015
 os/arch:   linux/amd64

如上所示可以看到server中apiversion(remote api的版本)

通过unix:///var/run/docker.sock访问

注意发送http请求时输入完get信息后要连按两次回车

?
1
2
3
4
5
6
7
8
9
10
eggyer@ubuntu:/usr/local/dockerfile/df_test1$ nc -u /var/run/docker.sock
get /info http/1.1
 
http/1.1 200 ok
content-type: application/json
server: docker/1.9.1 (linux)
date: sat, 26 nov 2016 14:33:45 gmt
content-length: 1162
 
{"id":"wbmi:td6b:prun:xwsx:5rvv:quyo:5s27:w74l:mq3w:ydb7:jxpl:nr5x","containers":12,"images":11,"driver":"aufs","driverstatus":[["root dir","/var/lib/docker/aufs"],["backing filesystem","extfs"],["dirs","35"],["dirperm1 supported","true"]],"memorylimit":true,"swaplimit":false,"cpucfsperiod":true,"cpucfsquota":true,"ipv4forwarding":true,"bridgenfiptables":true,"bridgenfip6tables":true,"debug":false,"nfd":19,"oomkilldisable":true,"ngoroutines":33,"systemtime":"2016-11-26t22:33:45.641108177+08:00","executiondriver":"native-0.2","loggingdriver":"json-file","neventslistener":0,"kernelversion":"4.4.0-47-generic","operatingsystem":"ubuntu 16.04.1 lts (containerized)","indexserveraddress":"https://index.docker.io/v1/","registryconfig":{"insecureregistrycidrs":["127.0.0.0/8"],"indexconfigs":{"docker.io":{"name":"docker.io","mirrors":null,"secure":true,"official":true}},"mirrors":null},"initsha1":"","initpath":"/usr/bin/docker","ncpu":4,"memtotal":4125528064,"dockerrootdir":"/var/lib/docker","httpproxy":"","httpsproxy":"","noproxy":"","name":"ubuntu","labels":null,"experimentalbuild":false,"serverversion":"1.9.1","clusterstore":"","clusteradvertise":""}

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

原文链接:http://blog.csdn.net/qq_22841811/article/details/53447597