美文网首页
docker打开api remote接口设置

docker打开api remote接口设置

作者: Future魏来 | 来源:发表于2018-01-26 20:59 被阅读45次

本文记录docker怎么打开api remote接口设置,docker的版本更新太快了,不同的版本之间,设置可能不同,本文是针对docker13.1

1、 查看配置文件位于哪里

systemctl show --property=FragmentPath docker 

2、编辑配置文件内容,接收所有ip请求

vim  /lib/systemd/system/docker.service 
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H tcp://0.0.0.0:5678

3、重新加载配置文件,重启docker daemon

sudo systemctl daemon-reload 
sudo systemctl restart docker

4、测试

[root@node1 docker]# docker -H localhost:5678 version
Client:
 Version: 1.13.1 API version: 1.26 Go version:   go1.7.5 Git commit:   092cba3
 Built:        Wed Feb 8 06:38:28 2017 OS/Arch:      linux/amd64

Server:
 Version: 1.13.1 API version: 1.26 (minimum version 1.12)
 Go version:   go1.7.5 Git commit:   092cba3
 Built:        Wed Feb 8 06:38:28 2017 OS/Arch:      linux/amd64
 Experimental: false [root@node1 docker]# curl -v -X GET localhost:5678/_ping * About to connect() to localhost port 5678 (#0) *   Trying ::1... * Connected to localhost (::1) port 5678 (#0) > GET /_ping HTTP/1.1
> User-Agent: curl/7.29.0
> Host: localhost:5678
> Accept: */* > 
< HTTP/1.1 200 OK
< Api-Version: 1.26
< Docker-Experimental: false
< Server: Docker/1.13.1 (linux)
< Date: Wed, 29 Nov 2017 08:58:12 GMT
< Content-Length: 2
< Content-Type: text/plain; charset=utf-8
< 
* Connection #0 to host localhost left intact
OK[root@node1 docker]# systemctl show --property=FragmentPath docker 
FragmentPath=/usr/lib/systemd/system/docker.service

表示docker remote api打开成功

本文出处: https://www.cnblogs.com/520playboy/p/7921633.html

相关文章

网友评论

      本文标题:docker打开api remote接口设置

      本文链接:https://www.haomeiwen.com/subject/xjawaxtx.html