2015-11-06 77 views
0

我在ubuntu 14.04上安裝了docker,它工作正常。如何使用docker遠程API?

etc/default/docker下,我有這樣的配置:

# 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" 

# 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 run hello-world然後var/run/docker.sock下的文件不被寫入。

如何從該文件收聽以便使用remote api

在此先感謝。

回答

1

如果你看到這樣的「Using boot2docker to run Docker on a Mac or Windows

$ docker run hello-world 
2014/08/11 15:05:55 Post http:///var/run/docker.sock/v1.13/containers/create: dial unix /var/run/docker.sock: no such file or directory 

所示的錯誤信息,請確保您已正確設置DOCKER_HOST環境變量。
隨着docker machine,應與設置:

docker-machine env dev 

一旦做到這一點,那麼一個簡單的GET應該工作:

echo -e "GET /images/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock 

它使用Netcat utilitync命令)。

+0

我沒有看到任何錯誤。 '此消息表明您的安裝似乎正常工作.' – OiRc

+0

您能提供給我任何提示嗎? – OiRc

+0

@OiRc您使用的是什麼碼頭版本?你試過請求來測試它是否會工作(如http://blog.inovia-conseil.fr/?p=215):'echo -e「GET/info HTTP/1.0rn」| sudo nc -U/var/run/docker.sock' – VonC

相關問題