Centos Docker1.12 远程Rest api访问的配置方法
Docker默认是没有开启HTTP远程访问的,默认只支持通过unixsocket通信操作dockerdaemon,需要使用HTTPrestful接口需要修改配置。
1、修改配置文件,文件位置/lib/systemd/system/docker.service。将原来的ExecStart修改为:
[Unit] Description=DockerApplicationContainerEngine Documentation=https://docs.docker.com After=network.target [Service] Type=notify #thedefaultisnottousesystemdforcgroupsbecausethedelegateissuesstill #existsandsystemdcurrentlydoesnotsupportthecgroupfeaturesetrequired #forcontainersrunbydocker #ExecStart=/usr/bin/dockerd #ExecStart=/usr/bin/dockerd-H192.168.25.130:2375 ExecStart=/usr/bin/dockerdaemon--tls=false-Hunix:///var/run/docker.sock-Htcp://192.168.25.130:2375 ExecReload=/bin/kill-sHUP$MAINPID #Havingnon-zeroLimit*scausesperformanceproblemsduetoaccountingoverhead #inthekernel.Werecommendusingcgroupstodocontainer-localaccounting. LimitNOFILE=infinity LimitNPROC=infinity LimitCORE=infinity #UncommentTasksMaxifyoursystemdversionsupportsit. #Onlysystemd226andabovesupportthisversion. #TasksMax=infinity TimeoutStartSec=0 #setdelegateyessothatsystemddoesnotresetthecgroupsofdockercontainers Delegate=yes #killonlythedockerprocess,notallprocessesinthecgroup KillMode=process [Install] WantedBy=multi-user.target
2.执行
systemctldaemon-reload systemctlrestartdocker.service
注:如果docker命令是无法使用的请在、etc/profile中配置:
exportDOCKER_HOST='http://192.168.25.128:2375'
是之生效
source/etc/profile
3、官方API说明文档
官方链接:DockerRemoteAPIv1.24
以上所述是小编给大家介绍的CentosDocker1.12远程Restapi访问,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对毛票票网站的支持!