@@ -16,7 +16,6 @@ import (
1616 "github.com/docker/docker/api/types/filters"
1717 "github.com/docker/docker/api/types/image"
1818 "github.com/docker/docker/api/types/mount"
19- "github.com/docker/docker/api/types/network"
2019 "github.com/docker/docker/api/types/registry"
2120 "github.com/docker/docker/api/types/volume"
2221 "github.com/docker/docker/client"
@@ -66,25 +65,20 @@ func (r *dockerRunner) Run(ctx context.Context, opts ...runner.RunOption) (strin
6665 Mounts : mounts ,
6766 }
6867
69- nc := network.NetworkingConfig {
70- EndpointsConfig : map [string ]* network.EndpointSettings {},
71- }
72-
73- for _ , nw := range options .Networks {
74- nc .EndpointsConfig [nw ] = & network.EndpointSettings {NetworkID : nw }
75- }
68+ // TODO: network support
7669
77- rsp , err := r .client .ContainerCreate (ctx , & cc , & hc , & nc , nil , "" )
70+ rsp , err := r .client .ContainerCreate (ctx , & cc , & hc , nil , nil , "" )
7871 if err != nil {
7972 // span
8073 slog .ErrorContext (ctx , "failed to create container" , "image" , options .Image , "error" , err )
8174 return "" , err
8275 }
8376
8477 defer func () {
85- if err := r .remove (ctx , options .ID ); err != nil {
78+ cleanupCtx := context .WithoutCancel (ctx )
79+ if err := r .remove (cleanupCtx , options .ID ); err != nil {
8680 // span
87- slog .ErrorContext (ctx , "failed to remove container" , "containerID" , rsp .ID , "error" , err )
81+ slog .ErrorContext (cleanupCtx , "failed to remove container" , "containerID" , rsp .ID , "error" , err )
8882 }
8983 }()
9084
@@ -305,14 +299,18 @@ func (r *dockerRunner) remove(ctx context.Context, id string) error {
305299
306300 if err := r .client .ContainerStop (ctx , containerID , container.StopOptions {}); err != nil {
307301 // span
308- return err
302+ slog . ErrorContext ( ctx , "failed to stop container" , "containerID" , containerID , "error" , err )
309303 }
310304
311305 if err := r .client .ContainerRemove (ctx , containerID , container.RemoveOptions {RemoveVolumes : false , RemoveLinks : false , Force : true }); err != nil {
312306 // span
307+ slog .ErrorContext (ctx , "failed to remove container" , "containerID" , containerID , "error" , err )
313308 return err
314309 }
315310
311+ // span
312+ slog .InfoContext (ctx , "successfully removed container" , "containerID" , containerID )
313+
316314 return nil
317315}
318316
0 commit comments