<p>When I read the k8s source code, I found that both <strong>dockerService</strong> located in <code>pkg/kubelet/dockershim/docker_service.go</code> and <strong>DockerServer</strong> located in <code>pkg/kubelet/dockershim/remote/docker_server.go</code> seem to implement the interface of the <code>CRI shim server</code>.</p>
<p>But I don't understand the difference between the two, why do I need to distinguish between the two?</p>
<blockquote>
<p>k8s version is tag 1.23.1</p>
</blockquote>

moluzhui
<ul>
<li>DockerServer simply creates <strong>dockershim grpc server</strong></li>
</ul>
<pre><code>// DockerServer is the grpc server of dockershim.
type DockerServer struct {
    // endpoint is the endpoint to serve on.
    endpoint string
    // service is the docker service which implements runtime and image services.
    service DockerService
    // server is the grpc server.
    server *grpc.Server
}
...
// Start starts the dockershim grpc server.
func (s *DockerServer) Start() error {
    glog.V(2).Infof(&quot;Start dockershim grpc server&quot;)
    l, err := util.CreateListener(s.endpoint)
    if err != nil {
        return fmt.Errorf(&quot;failed to listen on %q: %v&quot;, s.endpoint, err)
    }
    // Create the grpc server and register runtime and image services.
    s.server = grpc.NewServer()
    runtimeapi.RegisterRuntimeServiceServer(s.server, s.service)
    runtimeapi.RegisterImageServiceServer(s.server, s.service)
    go func() {
        // Use interrupt handler to make sure the server to be stopped properly.
        h := interrupt.New(nil, s.Stop)
        err := h.Run(func() error { return s.server.Serve(l) })
        if err != nil {
            glog.Errorf(&quot;Failed to serve connections: %v&quot;, err)
        }
    }()
    return nil
}
</code></pre>
<ul>
<li>DockerService is the interface <strong>implement CRI remote service server</strong></li>
</ul>
<pre><code>// DockerService is the interface implement CRI remote service server.
type DockerService interface {
    runtimeapi.RuntimeServiceServer
    runtimeapi.ImageServiceServer
}

// **dockerService uses dockershim service to implement DockerService**.
</code></pre>
<hr />
<p>BTW, are you sure you will use in the future? From the latest (5 days ago) news:
<a href="https://kubernetes.io/blog/2022/01/07/kubernetes-is-moving-on-from-dockershim/" rel="nofollow noreferrer">Kubernetes is Moving on From Dockershim: Commitments and Next Steps</a>:</p>
<ul>
<li><strong>Kubernetes is removing dockershim in the upcoming v1.24 release.</strong></li>
<li><strong>If you use Docker Engine as a container runtime for your Kubernetes cluster, get ready to migrate in 1.24</strong></li>
<li><strong>Full removal is targeted in Kubernetes 1.24, in April 2022.</strong></li>
<li><strong>We'll support Kubernetes version 1.23, which includes dockershim, for another year in the Kubernetes project.</strong></li>
</ul>
