红联Linux门户
Linux帮助

Docker Rest API配置及调用

发布时间:2017-01-29 15:46:16来源:linux网站作者:小爷有点狂
默认情况下,Docker只允许通过unix socket通信操作Docker daemon,但有时我们想通过HTTP调用其Rest API,需单独配置启动参数。
 
为了使配置永久生效,在Ubuntu环境下修改其配置文件/etc/default/docker,加入DOCKER_OPTS="-H=unix:///var/run/docker.sock -H=0.0.0.0:6732",重启Docker服务,可通过浏览器访问设置主机:端口号(6372)/ Docker API操作Docker,后续会补充基于API如何做一个简单的管理工具,先来一张雏形图。
 
# Docker Upstart and SysVinit configuration file
# Customize location of Docker binary (especially for development testing).  
#DOCKER="/usr/local/bin/docker"
# Use DOCKER_OPTS to modify the daemon startup options.  
#DOCKER_OPTS="--dns 8.8.8.8 --dns 8.8.4.4"  
DOCKER_OPTS="-H=unix:///var/run/docker.sock -H=0.0.0.0:6732"  
# If you need Docker to use an HTTP proxy, it can also be specified here.  
#export http_proxy="http://127.0.0.1:3128/"
# This is also a handy place to tweak where Docker's temporary files go.  
#export TMPDIR="/mnt/bigdrive/docker-tmp"
Docker Rest API配置及调用
 
本文永久更新地址:http://www.linuxdiyf.com/linux/28034.html