Docker Rest API配置及呼叫
阿新 • • 發佈:2019-02-08
預設情況下,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"