Docker 1 12新功能探索(8) Remote Api 1 24
2021-06-18 22:08
标签:blog config log network logstash 技术 进制 group 分享 Docker的Remote Api并不是1.12才有的,Docker1.12的Remote Api升到了1.24。Remote api的使用在1.12中没有大的变化,稍微大一点的变化是到这个版本之后,二进制文件分裂成了主client的docker以及主server的dockerd了。在centos上通过systemd的配置变化不大,无非是将tcp://ip:port设定到启动的Option中而已,下面来看一下如何设定和简单使用。 可以看到只有unix socket的方式 使用curl确认remote api版本和docker版本信息 通过images/json来取得image列表 注意点:设定之后,DOCKER_HOST也需要设定,不然正常的docker cli无法正常执行。 没有container时,取得空的列表 启动一个container 确认结果 再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow Docker 1 12新功能探索(8) Remote Api 1 24 标签:blog config log network logstash 技术 进制 group 分享 原文地址:https://www.cnblogs.com/firsttry/p/10294156.html
事前确认
[root@host34 system]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2016-08-20 09:17:29 EDT; 5min ago
Docs: https://docs.docker.com
Main PID: 12409 (dockerd)
Memory: 31.5M
CGroup: /system.slice/docker.service
tq12409 /usr/bin/dockerd
mq12412 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-inte...
修正设定文件
[root@host34 system]# cp /usr/lib/systemd/system/docker.service /usr/lib/systemd/system/docker.service.bak
[root@host34 system]# vi /usr/lib/systemd/system/docker.service
[root@host34 system]# diff /usr/lib/systemd/system/docker.service /usr/lib/systemd/system/docker.service.bak
11c11
192.168.32.34:2375
---
> ExecStart=/usr/bin/dockerd
[root@host34 system]#
daemon-reload和重启docker
命令:systemctl daemon-reload
命令:systemctl restart docker
[root@host34 system]# systemctl daemon-reload
[root@host34 system]# systemctl restart docker
[root@host34 system]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2016-08-20 23:48:09 EDT; 10s ago
Docs: https://docs.docker.com
Main PID: 13063 (dockerd)
Memory: 21.7M
CGroup: /system.slice/docker.service
tq13063 /usr/bin/dockerd -H 192.168.32.34:2375
mq13067 docker-containerd -l unix:///var/run/docker/libcontainerd/docker-containerd.sock --shim docker-containerd-shim --metrics-inte...
确认remote api
[root@host34 system]# curl http://192.168.32.34:2375/version
{"Version":"1.12.1","ApiVersion":"1.24","GitCommit":"23cf638","GoVersion":"go1.6.3","Os":"linux","Arch":"amd64","KernelVersion":"3.10.0-327.28.2.el7.x86_64","Experimental":true}
[root@host34 system]#
通过remote api取得image list
[root@host34 system]# curl http://192.168.32.34:2375/images/json
[{"Id":"sha256:6a6aaff36c0e44069f53cb24325df1ab94ed1f8728fbf9d27a7dad77a0bb40e1","ParentId":"sha256:8bb55b6d05b4ad4b28f88d85d924c70456ba2154143cba35dd7941f225856b63","RepoTags":["harbor_log:latest"],"RepoDigests":null,"Created":1471476367,"Size":187937470,"VirtualSize":187937470,"Labels":{}},{"Id":"sha256:97701402d89b48ad96d546e2f6d31d85c0dfa14b62fc2d198df683203e316487","ParentId":"","RepoTags":["sonarqube:latest"],"RepoDigests":["sonarqube@sha256:88845581b9d2ece8822c610f3430769d638298784a421186fe41850a7311bd31"],"Created":1470946631,"Size":790910817,"VirtualSize":790910817,"Labels":{}},{"Id":"sha256:f8d79ba03c00bbcd8079cf05b7526ac8f4f422744aad8c3747a29a38ed8c4a41","ParentId":"","RepoTags":["ubuntu:latest"],"RepoDigests":["ubuntu@sha256:8e2324f2288c26e1393b63e680ee7844202391414dbd48497e9a4fd997cd3cbf"],"Created":1470937589,"Size":126368859,"VirtualSize":126368859,"Labels":{}},{"Id":"sha256:ff60113363279ed0eb02aadd3149368b414dcf9baa4d3ce3c1fc8b6f4a03875e","ParentId":"","RepoTags":["ubuntu:14.04"],"RepoDigests":["ubuntu@sha256:ef500a237fb51cea075b270d811601c7226097f61b34a8ed4b4aa4e350a2c66d"],"Created":1470937563,"Size":187935394,"VirtualSize":187935394,"Labels":{}},{"Id":"sha256:ddb795388d57a4e04872558c9bf9a8a16bd0fd86421575daadedc80ad4492db5","ParentId":"","RepoTags":["elasticsearch:latest"],"RepoDigests":["elasticsearch@sha256:6eecc2f2878a05bfc7a8f01e2b8f2f2ce8e5c3adb0799c8ef15248dbf1bb7815"],"Created":1470936135,"Size":345057490,"VirtualSize":345057490,"Labels":{}},{"Id":"sha256:2baf469627a99bf5391b9787e24c6cfddb501f42af87438958d3c2eb15d937d1","ParentId":"","RepoTags":["logstash:latest"],"RepoDigests":["logstash@sha256:5c8bcc7785eedf69043ec758d72fc3edc3a6a965067c87084168fff0eb534644"],"Created":1470856281,"Size":461494743,"VirtualSize":461494743,"Labels":{}},{"Id":"sha256:741f9784699093113c250d6669f9f61e22adfb8cce058bb5e7fa15ab6f497cff","ParentId":"","RepoTags":["kibana:latest"],"RepoDigests":["kibana@sha256:a32096e588ba49b87fd2e146d4d60aecb620219006afea1aa55e44528d127fa2"],"Created":1470263992,"Size":297003643,"VirtualSize":297003643,"Labels":{}},{"Id":"sha256:2b8fd9751c4c0f5dd266fcae00707e67a2545ef34f9a29354585f93dac906749","ParentId":"","RepoTags":["busybox:latest"],"RepoDigests":["busybox@sha256:a59906e33509d14c036c8678d687bd4eec81ed7c4b8ce907b888c607f6a1e0e6"],"Created":1466724217,"Size":1092588,"VirtualSize":1092588,"Labels":{}},{"Id":"sha256:0d409d33b27e47423b049f7f863faa08655a8c901749c2b25b93ca67d01a470d","ParentId":"","RepoTags":["nginx:latest"],"RepoDigests":["nginx@sha256:0fe6413f3e30fcc5920bc8fa769280975b10b1c26721de956e1428b9e2f29d04"],"Created":1464804059,"Size":182735995,"VirtualSize":182735995,"Labels":{}}]
[root@host34 system]#
[root@host34 system]# export DOCKER_HOST=tcp://192.168.32.34:2375
[root@host34 system]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
harbor_log latest 6a6aaff36c0e 3 days ago 187.9 MB
sonarqube latest 97701402d89b 9 days ago 790.9 MB
ubuntu latest f8d79ba03c00 9 days ago 126.4 MB
ubuntu 14.04 ff6011336327 9 days ago 187.9 MB
elasticsearch latest ddb795388d57 9 days ago 345.1 MB
logstash latest 2baf469627a9 10 days ago 461.5 MB
kibana latest 741f97846990 2 weeks ago 297 MB
busybox latest 2b8fd9751c4c 8 weeks ago 1.093 MB
nginx latest 0d409d33b27e 11 weeks ago 182.7 MB
[root@host34 system]#
取得container list
[root@host34 system]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@host34 system]#
[root@host34 system]# curl http://192.168.32.34:2375/containers/json
[]
[root@host34 system]#
[root@host34 system]# docker run -d nginx
7736b16a2b78a420cdff1a5882579a071f55543f54d10856a2a06e20eca61d02
[root@host34 system]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
7736b16a2b78 nginx "nginx -g ‘daemon off" 9 seconds ago Up 5 seconds 80/tcp, 443/tcp thirsty_jang
[root@host34 system]#
[root@host34 system]# curl http://192.168.32.34:2375/containers/json
[{"Id":"7736b16a2b78a420cdff1a5882579a071f55543f54d10856a2a06e20eca61d02","Names":["/thirsty_jang"],"Image":"nginx","ImageID":"sha256:0d409d33b27e47423b049f7f863faa08655a8c901749c2b25b93ca67d01a470d","Command":"nginx -g ‘daemon off;‘","Created":1471751666,"Ports":[{"PrivatePort":443,"Type":"tcp"},{"PrivatePort":80,"Type":"tcp"}],"Labels":{},"State":"running","Status":"Up 52 seconds","HostConfig":{"NetworkMode":"default"},"NetworkSettings":{"Networks":{"bridge":{"IPAMConfig":null,"Links":null,"Aliases":null,"NetworkID":"839a3e2f0e9c49cfa8e12c5eef8916ba85940d41ac43b81601366c63c70441b3","EndpointID":"d288b3f97d794e2a94bf14b8d233614116245cbfa3558bb780120049d75560e3","Gateway":"172.17.0.1","IPAddress":"172.17.0.2","IPPrefixLen":16,"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,"MacAddress":"02:42:ac:11:00:02"}}},"Mounts":[]}]
[root@host34 system]#
文章标题:Docker 1 12新功能探索(8) Remote Api 1 24
文章链接:http://soscw.com/index.php/essay/95680.html