当前位置: 移动技术网 > 网络运营>服务器>虚拟主机 > Centos Docker1.12 远程Rest api访问的配置方法

Centos Docker1.12 远程Rest api访问的配置方法

2019年04月20日  | 移动技术网网络运营  | 我要评论

docker默认是没有开启http远程访问的,默认只支持通过unix socket通信操作docker daemon,需要使用http restful接口需要修改配置。

1、修改配置文件,文件位置/lib/systemd/system/docker.service。将原来的execstart修改为:

[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.执行

systemctl daemon-reload
systemctl restart docker.service

注:如果docker命令是无法使用的请在、etc/profile中配置:

export docker_host= 'http://192.168.25.128:2375'

是之生效

source /etc/profile

3、官方api说明文档

官方链接:docker remote api v1.24

以上所述是小编给大家介绍的centos docker1.12 远程rest api访问,希望对大家有所帮助

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网