File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -40,6 +40,14 @@ func NewStopCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command {
4040 errors .CheckError (err )
4141 defer containerClient .CloseClient ()
4242
43+ exists , _ := containerClient .ContainerExists (instance .ContainerID )
44+ errors .CheckError (err )
45+ if ! exists {
46+ fmt .Printf ("Container for instance %s no longer exists\n " , instance .Name )
47+ fmt .Printf ("Run 'microcks start --name %s' to bring the container back\n " , instance .Name )
48+ return
49+ }
50+
4351 err = containerClient .StopContainer (instance .ContainerID )
4452 if err != nil {
4553 log .Fatalf ("Failed to stop a container: %v" , err )
@@ -59,7 +67,7 @@ func NewStopCommand(globalClientOpts *connectors.ClientOptions) *cobra.Command {
5967 _ = localConfig .RemoveServer (ctx .Server .Server )
6068 _ = localConfig .RemoveUser (ctx .User .Name )
6169 _ = localConfig .RemoveAuth (ctx .Server .Server )
62- _ = localConfig .RemoveInstance (instance .ContainerID )
70+ _ = localConfig .RemoveInstance (instance .Name )
6371
6472 localConfig .CurrentContext = ""
6573 log .Printf ("Instance %s removed successfully" , instance .Name )
You can’t perform that action at this time.
0 commit comments