编译调试docker

作者: AEGQ | 来源:发表于2017-06-20 14:01 被阅读85次

参考:


示例:


1、编译 dockerd

$ git clone https://github.com/moby/moby.git
$ cd moby && make BIND_DIR=. shell
root@697ab9a6fb54:/go/src/github.com/docker/docker# hack/make.sh binary install-binary run
$ docker exec -it 697ab9a6fb54 bash
root@697ab9a6fb54:/go/src/github.com/docker/docker# ls bundles/17.06.0-dev/binary-daemon/
docker-containerd      docker-containerd-ctr.sha256  docker-containerd-shim.sha256  docker-init     docker-proxy     docker-runc         dockerd              dockerd-17.06.0-dev.sha256
docker-containerd-ctr      docker-containerd-shim    docker-containerd.md5      docker-init.md5     docker-proxy.md5     docker-runc.md5     dockerd-17.06.0-dev
docker-containerd-ctr.md5  docker-containerd-shim.md5    docker-containerd.sha256   docker-init.sha256  docker-proxy.sha256  docker-runc.sha256  dockerd-17.06.0-dev.md5

2、编译 docker

root@697ab9a6fb54:/go/src/github.com/docker/docker# cd .. && git clone https://github.com/docker/cli.git
root@697ab9a6fb54:/go/src/github.com/docker/cli# make binary
root@697ab9a6fb54:/go/src/github.com/docker/cli# ls build/
docker  docker-linux-amd64

3、调试

root@697ab9a6fb54:/go/src/github.com/docker/cli# git diff
diff --git a/cli/command/container/attach.go b/cli/command/container/attach.go
index dce6432..9384b0d 100644
--- a/cli/command/container/attach.go
+++ b/cli/command/container/attach.go
@@ -56,7 +56,7 @@ func NewAttachCommand(dockerCli command.Cli) *cobra.Command {
        }
 
        flags := cmd.Flags()
-       flags.BoolVar(&opts.noStdin, "no-stdin", false, "Do not attach STDIN")
+       flags.BoolVar(&opts.noStdin, "no-stdin", false, "Do not attach STDIN (standard in)")
        flags.BoolVar(&opts.proxy, "sig-proxy", true, "Proxy all received signals to the process")
        flags.StringVar(&opts.detachKeys, "detach-keys", "", "Override the key sequence for detaching a container")
        return cmd


root@697ab9a6fb54:/go/src/github.com/docker/cli/build# ./docker-linux-amd64 attach --help

Usage:  docker attach [OPTIONS] CONTAINER

Attach local standard input, output, and error streams to a running container

Options:
      --detach-keys string   Override the key sequence for detaching a container
      --help                 Print usage
      --no-stdin             Do not attach STDIN (standard in)
      --sig-proxy            Proxy all received signals to the process (default true)

4、测试: dockerd默认访问私有仓库

root@697ab9a6fb54:/go/src/github.com/docker/docker/registry# git diff config.go 
diff --git a/registry/config.go b/registry/config.go
index 651bd73..c494604 100644
--- a/registry/config.go
+++ b/registry/config.go
@@ -52,8 +52,10 @@ var (
 
        // DefaultV2Registry is the URI of the default v2 registry
        DefaultV2Registry = &url.URL{
-               Scheme: "https",
-               Host:   "registry-1.docker.io",
+               //Scheme: "https",
+               //Host:   "registry-1.docker.io",
+               Scheme: "http",
+               Host:   "private.registry.com:5000",
        }
 )
 

相关文章

网友评论

    本文标题:编译调试docker

    本文链接:https://www.haomeiwen.com/subject/rqagqxtx.html