dongping5230 2017-02-10 21:22
浏览 569
已采纳

Docker服务更新错误:EOF

We have a GO application that listens for code repo changes and Redis messages in order to apply CD in a Docker Swarm environment. That application was recently updated to use the github.com/docker/docker v1.13.1 client code. It worked on my mac, which runs Docker v1.13.1. When I deploy this code to a development server running Ubuntu and Docker v1.12.6, I get an "EOF" error when trying to call cli.ServiceUpdate(..). As far as I know, the CLI client is backwards compatible (until v1.10.x or something). When looking at the code and the screenshot, the connection between the two is the log message of "An error occurred while updating a service".

Event thought we are using the v1.13.1 version of the golang libraries, we specify the api version v1.24 in our client initialization:

func createClient() {
    if cli == nil {
        defaultHeaders := map[string]string{"User-Agent": "engine-api-cli-1.0"}
        var err error
        cli, err = client.NewClient("unix:///var/run/docker.sock", "v1.24", nil, defaultHeaders)
        if err != nil {
            panic(err)
        }
    }
}

Here is the offending code:

func updateService(s configuration.Service, version string) {
    createClient()

    ctx := context.Background()

    service, _, err := cli.ServiceInspectWithRaw(ctx, configuration.ServiceName(s))
    if err != nil {
        fmt.Println("could not find service", err)
        return
    }

    serviceSpec := createServiceSpec(s, version)

    encodedRegistryAuth := createEncodedRegistryAuth()
    var resp types.ServiceUpdateResponse
    resp, err = cli.ServiceUpdate(ctx, service.ID, service.Version, serviceSpec, types.ServiceUpdateOptions{EncodedRegistryAuth: encodedRegistryAuth})
    if err != nil {
        fmt.Println("An error occurred while updating a service: ", s.Service, "; ", err)
    } else {
        message := "SERVICE UPDATE - " + s.Service + "_" + s.Channel + " >> " + envName + ":" + s.Service + ":" + version
        connections.SlackMessage(message)
        connections.NewRelicDeploy(version, message)
        connections.GrafanaDeploy(version, message)
        fmt.Println("Updated service", s.Service, "and waiting", s.UpdateDelay)
        fmt.Println("Warnings from service update", resp.Warnings)
    }
}

Here is a screen grab of what happened in syslog:

Docker Syslog

Here is the output from docker info:

Client:
 Version:      1.12.6
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   78d1802
 Built:        Tue Jan 10 20:40:44 2017
 OS/Arch:      linux/amd64
 Experimental: true

Server:
 Version:      1.12.6
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   78d1802
 Built:        Tue Jan 10 20:40:44 2017
 OS/Arch:      linux/amd64
 Experimental: true

Any ideas on what I could be doing wrong?

  • 写回答

1条回答 默认 最新

  • doumibi6899 2017-02-13 16:04
    关注

    Turned out to be a fluke somewhere. We rebuilt the swarm by stopping the docker daemon, removing /var/lib/docker, and starting the daemon back up. After that the error no longer occurred.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)