docker容器找不到unix socket

时间:2015-12-30 16:53:29

标签: java sockets unix docker

我有一个docker容器,我想从中生成一个新容器。我正在使用com.spotify:docker-client:3.3.5进行通信。 docker version的输出如下所示,docker images的输出和docker unix socket的回显。

我正在运行的代码是

final DockerClient docker = DefaultDockerClient.builder()
        .uri(URI.create("unix:///var/run/docker.sock")).build();

String image = "docker.mydom.net/stock-availability:v1";
final ImageInfo imageInfo;

try {
    imageInfo = docker.inspectImage(image);
} catch (DockerException e) {
    return "(2) " + e.toString();
} catch (InterruptedException e){
        return "(3) " + e.toString();
}

我看到的是找不到文件的错误。似乎问题在于使用unix socket,但我不明白什么是错的。我不想打开TCP端口,套接字仅限于docker组。任何帮助都将被感激地接受!

2015-12-30 16:36:35.192  INFO 1 --- [sync-executor-0] o.apache.http.impl.execchain.RetryExec   : I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory
2015-12-30 16:36:35.193  INFO 1 --- [sync-executor-0] o.apache.http.impl.execchain.RetryExec   : Retrying request to {}->unix://localhost:80
2015-12-30 16:36:35.194  INFO 1 --- [sync-executor-0] o.apache.http.impl.execchain.RetryExec   : I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory
2015-12-30 16:36:35.194  INFO 1 --- [sync-executor-0] o.apache.http.impl.execchain.RetryExec   : Retrying request to {}->unix://localhost:80
2015-12-30 16:36:35.194  INFO 1 --- [sync-executor-0] o.apache.http.impl.execchain.RetryExec   : I/O exception (java.io.IOException) caught when processing request to {}->unix://localhost:80: No such file or directory
2015-12-30 16:36:35.194  INFO 1 --- [sync-executor-0] o.apache.http.impl.execchain.RetryExec   : Retrying request to {}->unix://localhost:80
com.spotify.docker.client.DockerException: java.util.concurrent.ExecutionException: javax.ws.rs.ProcessingException: java.io.IOException: No such file or directory



0 ✓ docker@docker-002  ~/stock_availability $ docker version
Client:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:25:01 UTC 2015
 OS/Arch:      linux/amd64

Server:
 Version:      1.9.1
 API version:  1.21
 Go version:   go1.4.2
 Git commit:   a34a1d5
 Built:        Fri Nov 20 13:25:01 UTC 2015
 OS/Arch:      linux/amd64

0 ✓ docker@docker-002  ~/stock_availability $ docker images
REPOSITORY                             TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
docker.mydom.net/login                v1                  2913b9ab6f65        59 minutes ago      489.4 MB
docker.mydom.net/stock-availability   v1                  626fb30c8d08        7 days ago          463.6 MB
docker.mydom.net/java                 jre-8               6675c4c07738        11 weeks ago        423.2 MB

130 ✗ docker@docker-002  ~/stock_availability $ echo -e "GET /images/docker.mydom.net/stock-availability:v1/json HTTP/1.0\r\n" | nc -U /var/run/docker.sock
HTTP/1.0 200 OK
Content-Type: application/json
Server: Docker/1.9.1 (linux)
Date: Wed, 30 Dec 2015 16:45:06 GMT
Content-Length: 1738

{"Id":"626fb30c8d08..<snip>..400"}}}
0 ✓ docker@gb1-li-docker-002  ~/stock_availability $

0 个答案:

没有答案