Centos Docker1.12 远程Rest api访问的配置方法
程序员文章站
2022-04-06 10:06:34
docker默认是没有开启http远程访问的,默认只支持通过unix socket通信操作docker daemon,需要使用http restful接口需要修改配置。...
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说明文档
以上所述是小编给大家介绍的centos docker1.12 远程rest api访问,希望对大家有所帮助
推荐阅读