如何在macOS上从源代码构建docker-ce [英] How to build docker-ce from source on macOS

查看:176
本文介绍了如何在macOS上从源代码构建docker-ce的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道是否有从源代码构建并在Mac上用它替换docker二进制文件的指南吗?

Anyone knows if there's a guide to build from source and replace docker binary on Mac with it?

自述文件没有说明,所以我尝试了一些make target,但得到了 https://github.com/docker/for-mac/issues/3353

The readme doesn't say so I try some make target but got https://github.com/docker/for-mac/issues/3353

已编辑
我想做的就是调试docker cli来查看为什么我的旧公司的Auth不适用于单个开发人员,而不管所有因素都经过检查和验证是否正确。

Edited What I was trying to do, to be exact, is to debug docker cli to see why the Auth doesn't work for a single developer in my former company, regardless all factor checked and verified to be correct.

推荐答案

由于在macOS上不会运行引擎,因此可以尝试其他方法。使用Makefile构建 docker 客户端需要docker引擎和一个docker client,而您可能没有。

Since on macOS you're not going to run the engine, you may try a different approach. Building the docker client using the Makefile requires docker engine, and a docker client, which you may not have.

我正在从docker / cli存储库中构建 docker (客户端)作为一个普通的Go项目:

I'm building docker (the client) from the docker/cli repository as a plain Go project:


  • 克隆仓库:

  • Clone the repo:

$ git clone https://github.com/docker/cli.git


  • 构建 master ,或签出特定标签:

  • Build master, or checkout a specific tag:

    $ git checkout v19.03.6
    


  • cd 进入存储库,创建构建目录,并创建require Go项目结构:

  • cd into the repo, create a build directory, and create the require Go project structure:

    $ cd cli
    $ mkdir -p build/src/github.com/
    $ cd build/src/github.com/
    $ ln -s ../../.. cli
    


  • cd 进入 build 目录并设置 GOPATH

    $ cd ../..
    $ export GOPATH=$(pwd)
    


  • 构建 docker 客户端:

    $ go build github.com/docker/cli/cmd/docker
    


  • build 目录,例如:

    $ cp docker /usr/local/bin
    


  • 您会注意到一些与构建相关的未设置信息:

    You'll notice that some build-related information is not set:

    ./docker version
    Client:
     Version:           unknown-version
     API version:       1.40
     Go version:        go1.13.8
     Git commit:        unknown-commit
     Built:             unknown-buildtime
     OS/Arch:           darwin/amd64
     Experimental:      false
    

    您可以传递适当的 -ldflags 参数以将这些变量设置为:

    You can pass a suitable -ldflags argument to set those variables as in:

    $ go build \
        -ldflags \
        "-X github.com/docker/cli/cli/version.GitCommit=${docker_gitcommit} \
         -X github.com/docker/cli/cli/version.Version=${version} \
         -X \"github.com/docker/cli/cli/version.BuildTime=${build_time}\""
    

    只要您已设置 docker_gitcommit 版本 build_time 变量。如果 build_time 包含空格(如上游 docker 二进制文件一样),则需要在第三个标志中使用转义引号。

    provided you have set the docker_gitcommit, version and build_time variables. The escaped quotes in the third flag are required if build_time contain spaces (as the upstream docker binaries do).

    希望这会有所帮助。

    这篇关于如何在macOS上从源代码构建docker-ce的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆