doufan6544
doufan6544
2019-07-01 12:08

Docker Engine API-通过对等方重置连接

  • docker

I'm trying to make requests to the Docker API remotely.

I have the docker engine running on virtual machine, and I'm making the requests from docker containers.

Firstly, I've done this to make the Docker daemon listen on a specific IP and port:

edit /lib/systemd/system/docker.service 
ExecStart=/usr/bin/docker -H fd:// -H=tcp://0.0.0.0:5555
systemctl daemon-reload
sudo service docker restart

I configured to listen on 0.0.0.0, so it will be reachable at any IPv4 address.

When I test this via curl on host, it works fine. e.g: curl localhost:5555/services

However, my goal is to make requests from containers. Here is how I construct the docker client inside my go program:

cli, err := client.NewClientWithOpts(
     client.WithHost("tcp://192.168.56.1:5555"),
)
if err != nil {
     panic(err)
}

networkFilters := filters.NewArgs()
networkFilters.Add("driver", "overlay")
networks, err := cli.NetworkList(context.Background(), types.NetworkListOptions{Filters: networkFilters})
if err != nil {
    panic(err)
}

The error I'm having:

http: panic serving 10.255.0.2:39632: error during connect: Get http://192.168.56.1:5555/v1.40/networks?filters=%7B%22driver%22%3A%7B%22overlay%22%3Atrue%7D%7D: read tcp 172.18.0.3:36126->192.168.56.1:5555: read: connection reset by peer

Any ideas? Thanks

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

0条回答