@@ -33,14 +33,14 @@ type ContainerController struct {
3333}
3434
3535type container struct {
36- imageConfig types.ImageInspect
37- m sync.RWMutex
36+ imageConfig * types.ImageInspect
37+ m sync.RWMutex
3838 * model.Container
3939}
4040
41- func newContainer (id , name string ) * container {
41+ func newContainer (id , name string , imageConfig * types. ImageInspect ) * container {
4242 c := model .NewContainer (id , name )
43- return & container {Container : c }
43+ return & container {Container : c , imageConfig : imageConfig }
4444}
4545
4646const eventBufferLen = 512
@@ -104,7 +104,12 @@ func (cc *ContainerController) start(ctx context.Context) error {
104104 }
105105 log .L .Debug (ce )
106106 if _ , exists := cc .containers [containerID ]; ! exists {
107- container := newcontainer (ce .containerID , containerName )
107+ config , err := cc .imageConfig (ctx , ce .image )
108+ if err != nil {
109+ log .L .WithError (err ).WithField ("container-id" , containerID ).Error ("cant fetch image config" )
110+ continue
111+ }
112+ container := newContainer (ce .containerID , containerName , config )
108113 ch := make (chan containerEvent , eventBufferLen )
109114 cc .cm .Lock ()
110115 cc .containers [containerID ] = container
@@ -131,6 +136,14 @@ func (cc *ContainerController) start(ctx context.Context) error {
131136 return nil
132137}
133138
139+ func (cc * ContainerController ) imageConfig (ctx context.Context , id string ) (* types.ImageInspect , error ) {
140+ imageConfig , _ , err := cc .dockerCli .ImageInspectWithRaw (ctx , id )
141+ if err != nil {
142+ return nil , err
143+ }
144+ return & imageConfig , nil
145+ }
146+
134147func convert (e sysdig.Event ) containerEvent {
135148 res := containerEvent {}
136149 res .containerID = e .ContainerID
@@ -146,5 +159,6 @@ func convert(e sysdig.Event) containerEvent {
146159 res .rawRes = e .RawRes
147160 res .syscallType = e .SyscallType
148161 res .virtualtid = e .ThreadVirtualID
162+ res .image = e .ContainerImage
149163 return res
150164}
0 commit comments