@@ -70,6 +70,7 @@ type IContainerService interface {
7070 ContainerUpgrade (req dto.ContainerUpgrade ) error
7171 ContainerInfo (req dto.OperationWithName ) (* dto.ContainerOperate , error )
7272 ContainerListStats () ([]dto.ContainerListStats , error )
73+ ContainerItemStats (containerID string ) (dto.ContainerItemStats , error )
7374 LoadResourceLimit () (* dto.ResourceLimit , error )
7475 ContainerRename (req dto.ContainerRename ) error
7576 ContainerCommit (req dto.ContainerCommit ) error
@@ -101,10 +102,7 @@ func (u *ContainerService) Page(req dto.PageContainer) (int64, interface{}, erro
101102 return 0 , nil , err
102103 }
103104 defer client .Close ()
104- options := container.ListOptions {
105- All : true ,
106- Size : true ,
107- }
105+ options := container.ListOptions {All : true }
108106 if len (req .Filters ) != 0 {
109107 options .Filters = filters .NewArgs ()
110108 options .Filters .Add ("label" , req .Filters )
@@ -259,6 +257,21 @@ func (u *ContainerService) LoadStatus() (dto.ContainerStatus, error) {
259257 }
260258 return data , nil
261259}
260+ func (u * ContainerService ) ContainerItemStats (containerID string ) (dto.ContainerItemStats , error ) {
261+ var data dto.ContainerItemStats
262+ client , err := docker .NewDockerClient ()
263+ if err != nil {
264+ return data , err
265+ }
266+ defer client .Close ()
267+ containerInfo , _ , err := client .ContainerInspectWithRaw (context .Background (), containerID , true )
268+ if err != nil {
269+ return data , err
270+ }
271+ data .SizeRw = * containerInfo .SizeRw
272+ data .SizeRootFs = * containerInfo .SizeRootFs
273+ return data , nil
274+ }
262275func (u * ContainerService ) ContainerListStats () ([]dto.ContainerListStats , error ) {
263276 client , err := docker .NewDockerClient ()
264277 if err != nil {
@@ -1760,8 +1773,6 @@ func searchWithFilter(req dto.PageContainer, containers []container.Summary) []d
17601773 ImageName : item .Image ,
17611774 State : item .State ,
17621775 RunTime : item .Status ,
1763- SizeRw : item .SizeRw ,
1764- SizeRootFs : item .SizeRootFs ,
17651776 IsFromApp : IsFromApp ,
17661777 IsFromCompose : IsFromCompose ,
17671778 }
0 commit comments