如何从源代码构建 Docker Machine?(20.04)

如何从源代码构建 Docker Machine?(20.04)

我需要从源代码构建 Docker Machine。我知道最简单的方法是使用 GOPATH,但我似乎找不到如何操作?

我的机器上有 Docker Machine 源代码,但它应该在哪里编译?官方 Docker 文档没有讨论这个问题。

有人可以提供步骤吗?我正在使用 Ubuntu 20.04

编辑:在源代码目录make中运行时 的输出:~/machine

...
...
/usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
/home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)
cmd/docker-machine/machine.go:10:2: cannot find package "github.com/codegangsta/cli" in any of:
    /usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
    /home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)
cmd/docker-machine/machine.go:10:2: cannot find package "github.com/codegangsta/cli" in any of:
    /usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
    /home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)
cmd/docker-machine/machine.go:10:2: cannot find package "github.com/codegangsta/cli" in any of:
    /usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
    /home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)
cmd/docker-machine/machine.go:10:2: cannot find package "github.com/codegangsta/cli" in any of:
    /usr/local/go/src/github.com/codegangsta/cli (from $GOROOT)
    /home/mark/go/src/github.com/codegangsta/cli (from $GOPATH)

答案1

GOPATH在您的机器上设置变量,请执行以下操作:

  1. 使用您喜欢的文本编辑器打开该~/.profile文件,并将以下两行添加到文件底部:
export GOPATH=$HOME/go
export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin
  1. 保存文件,然后重新加载您的个人资料:
$ source ~/.profile

这应该给你一个有效的GOPATH

相关内容