linux - 如何使用 Docker 远程 API?

标签 linux docker

我在 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/

相关文章:

java - 无法在 Java 中从 Linux 计算机连接到 Oracle 数据库

networking - Docker 将 LXC 与直接主机网络结合使用

linux - Docker 安全最佳实践

c - 在 Linux 中获取自 1984 年 1 月 1 日午夜以来的绝对时间

docker - docker内部的http调用错误证书由未知的权威机构签名

docker - 如何在 Docker 上发布 UDP 端口?

docker - 进行更改后,GitLab docker镜像不会从gitlab.rb重新配置某些参数

php - 多个网站的正确 Docker 设置

c - gcc 在 lib 中找不到函数

linux - 如果一个失败,如何同步访问三个linux