Skip to content

Commit

Permalink
Forcing the containert to stop when changing bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
FlUxIuS committed Dec 4, 2024
1 parent a1a96cb commit 31e6265
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions go/rfswift/dock/rfdock.go
Original file line number Diff line number Diff line change
Expand Up @@ -1596,6 +1596,20 @@ func UpdateMountBinding(containerName string, source string, target string, add
}
common.PrintSuccessMessage(fmt.Sprintf("Container ID: %s", containerID))

// Stop the container
cli, err := client.NewClientWithOpts(client.FromEnv)
if err != nil {
common.PrintErrorMessage(fmt.Errorf("Error when instanciating a client"))
os.Exit(1)
}
common.PrintInfoMessage("Stopping the container...")
err = cli.ContainerStop(ctx, containerID, container.StopOptions{})
if err != nil {
common.PrintErrorMessage(fmt.Errorf("Failed to stop the container"))
os.Exit(1)
}
common.PrintSuccessMessage(fmt.Sprintf("Container '%s' stopped", containerID))

common.PrintInfoMessage("Determining hostconfig.json path...")
configPath, err := GetHostConfigPath(containerID)
if err != nil {
Expand Down

0 comments on commit 31e6265

Please sign in to comment.