@@ -74,6 +74,7 @@ func (u *ContainerService) PageCompose(req dto.SearchWithPage) (int64, interface
7474 Name : container .Names [0 ][1 :],
7575 State : container .State ,
7676 CreateTime : time .Unix (container .Created , 0 ).Format (constant .DateTimeLayout ),
77+ Ports : transPortToStr (container .Ports ),
7778 }
7879 if compose , has := composeMap [name ]; has {
7980 compose .ContainerCount ++
@@ -180,7 +181,7 @@ func (u *ContainerService) TestCompose(req dto.ComposeCreate) (bool, error) {
180181 cmd := getComposeCmd (req .Path , "config" )
181182 stdout , err := cmd .CombinedOutput ()
182183 if err != nil {
183- return false , errors . New ( string (stdout ))
184+ return false , fmt . Errorf ( "docker-compose config failed, std: %s, err: %v" , string (stdout ), err )
184185 }
185186 return true , nil
186187}
@@ -242,14 +243,13 @@ func (u *ContainerService) ComposeOperation(req dto.ComposeOperation) error {
242243 }
243244 if req .Operation == "up" {
244245 if stdout , err := compose .Up (req .Path ); err != nil {
245- return errors . New ( string ( stdout ) )
246+ return fmt . Errorf ( "docker-compose up failed, std: %s, err: %v" , stdout , err )
246247 }
247248 } else {
248249 if stdout , err := compose .Operate (req .Path , req .Operation ); err != nil {
249- return errors . New ( string ( stdout ) )
250+ return fmt . Errorf ( "docker-compose %s failed, std: %s, err: %v" , req . Operation , stdout , err )
250251 }
251252 }
252- global .LOG .Infof ("docker-compose %s %s successful" , req .Operation , req .Name )
253253 return nil
254254}
255255
@@ -276,10 +276,11 @@ func (u *ContainerService) ComposeUpdate(req dto.ComposeUpdate) error {
276276 }
277277
278278 if stdout , err := compose .Up (req .Path ); err != nil {
279+ global .LOG .Errorf ("update failed when handle compose up, std: %s, err: %s, now try to recreate the old compose file" , stdout , err )
279280 if err := recreateCompose (string (oldFile ), req .Path ); err != nil {
280- return fmt .Errorf ("update failed when handle compose up, err: %s, recreate failed : %v" , string ( stdout ) , err )
281+ return fmt .Errorf ("update failed and recreate old compose file also failed, err : %v" , err )
281282 }
282- return fmt .Errorf ("update failed when handle compose up, err: %s" , string ( stdout ) )
283+ return fmt .Errorf ("update failed when handle compose up, std: %v, err: %s" , stdout , err )
283284 }
284285
285286 return nil
@@ -438,6 +439,5 @@ func newComposeEnv(pathItem string, env []string) error {
438439 return err
439440 }
440441 }
441- global .LOG .Infof (".env file successfully created or updated with env variables in %s" , envFilePath )
442442 return nil
443443}
0 commit comments