Docker默認是沒有開啟HTTP遠程訪問的,默認只支持通過unix socket通信操作docker daemon,需要使用HTTP restful接口需要修改配置。
1、修改配置文件,文件位置/lib/systemd/system/docker.service。將原來的ExecStart修改為:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
[Unit] Description=Docker Application Container Engine Documentation=https: //docs .docker.com After=network.target [Service] Type=notify # the default is not to use systemd for cgroups because the delegate issues still # exists and systemd currently does not support the cgroup feature set required # for containers run by docker #ExecStart=/usr/bin/dockerd #ExecStart=/usr/bin/dockerd -H 192.168.25.130:2375 ExecStart= /usr/bin/docker daemon --tls= false -H unix: ///var/run/docker .sock -H tcp: //192 .168.25.130:2375 ExecReload= /bin/kill -s HUP $MAINPID # Having non-zero Limit*s causes performance problems due to accounting overhead # in the kernel. We recommend using cgroups to do container-local accounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity # Uncomment TasksMax if your systemd version supports it. # Only systemd 226 and above support this version. #TasksMax=infinity TimeoutStartSec=0 # set delegate yes so that systemd does not reset the cgroups of docker containers Delegate= yes # kill only the docker process, not all processes in the cgroup KillMode=process [Install] WantedBy=multi-user.target |
2.執(zhí)行
1
2
|
systemctl daemon-reload systemctl restart docker.service |
注:如果docker命令是無法使用的請在、etc/profile中配置:
1
|
export DOCKER_HOST= 'http://192.168.25.128:2375' |
是之生效
1
|
source /etc/profile |
3、官方API說明文檔
官方鏈接:Docker Remote API v1.24
以上所述是小編給大家介紹的Centos Docker1.12 遠程Rest api訪問,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對服務(wù)器之家網(wǎng)站的支持!
原文鏈接:http://blog.csdn.net/wdxwxz/article/details/54093476