@@ -24,12 +24,14 @@ import (
2424 "net"
2525 "os"
2626 "os/exec"
27+ "path/filepath"
2728 goruntime "runtime"
2829 "strconv"
2930 "syscall"
3031 "time"
3132
3233 "github.com/containerd/containerd/api/types"
34+ "github.com/containerd/containerd/v2/defaults"
3335 "github.com/containerd/containerd/v2/pkg/namespaces"
3436 "github.com/containerd/containerd/v2/pkg/shim"
3537 "github.com/containerd/errdefs"
@@ -129,8 +131,8 @@ func (s *shimSocket) Close() {
129131 _ = shim .RemoveSocket (s .addr )
130132}
131133
132- func newShimSocket (ctx context.Context , path , id string , debug bool ) (* shimSocket , error ) {
133- address , err := shim .SocketAddress (ctx , path , id , debug )
134+ func newShimSocket (ctx context.Context , root , path , id string , debug bool ) (* shimSocket , error ) {
135+ address , err := shim .CreateSocketAddress (ctx , root , path , id , debug )
134136 if err != nil {
135137 return nil , err
136138 }
@@ -195,8 +197,11 @@ func (manager) Start(ctx context.Context, id string, opts shim.StartOpts) (_ shi
195197 }
196198 }
197199 }()
198-
199- s , err := newShimSocket (ctx , opts .Address , grouping , false )
200+ socketDir := opts .SocketDir
201+ if socketDir == "" {
202+ socketDir = filepath .Join (defaults .DefaultStateDir , "s" )
203+ }
204+ s , err := newShimSocket (ctx , socketDir , opts .Address , grouping , false )
200205 if err != nil {
201206 if errdefs .IsAlreadyExists (err ) {
202207 params .Address = s .addr
@@ -208,7 +213,7 @@ func (manager) Start(ctx context.Context, id string, opts shim.StartOpts) (_ shi
208213 cmd .ExtraFiles = append (cmd .ExtraFiles , s .f )
209214
210215 if opts .Debug {
211- s , err = newShimSocket (ctx , opts .Address , grouping , true )
216+ s , err = newShimSocket (ctx , socketDir , opts .Address , grouping , true )
212217 if err != nil {
213218 return params , err
214219 }
0 commit comments