我在 Ubuntu 14.04 上安装了 Docker,它工作正常。
在 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,我如何从那个文件中监听?
最佳答案
如果您看到类似“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 utility (nc
命令)。
关于linux - 如何使用 Docker 远程 API?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33563685/