mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-11 18:35:51 +02:00
fix(docker): [ota] stop old container
This commit is contained in:
parent
1f561a0dba
commit
123dd83b51
1 changed files with 7 additions and 0 deletions
|
@ -256,6 +256,12 @@ func UpgradeStepTwo(ctx context.Context) (err error) {
|
||||||
return errors.Wrap(err, "failed to rename old container")
|
return errors.Wrap(err, "failed to rename old container")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stop the old container
|
||||||
|
err = cli.ContainerStop(ctx, currentContainerName+OldSuffix, container.StopOptions{})
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrap(err, "failed to stop old container")
|
||||||
|
}
|
||||||
|
|
||||||
// 3. Use the old config to create and start a new container with the updated image
|
// 3. Use the old config to create and start a new container with the updated image
|
||||||
// Create new container with original config but using the new image
|
// Create new container with original config but using the new image
|
||||||
newContainerEnv := oldContainerInfo.Config.Env
|
newContainerEnv := oldContainerInfo.Config.Env
|
||||||
|
@ -302,6 +308,7 @@ func UpgradeStepTwo(ctx context.Context) (err error) {
|
||||||
// Start the new container
|
// Start the new container
|
||||||
err = cli.ContainerStart(ctx, currentContainerName, container.StartOptions{})
|
err = cli.ContainerStart(ctx, currentContainerName, container.StartOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Error("Failed to start new container:", err)
|
||||||
// If startup fails, try to recover
|
// If startup fails, try to recover
|
||||||
// First remove the failed new container
|
// First remove the failed new container
|
||||||
removeErr := cli.ContainerRemove(ctx, currentContainerName, container.RemoveOptions{Force: true})
|
removeErr := cli.ContainerRemove(ctx, currentContainerName, container.RemoveOptions{Force: true})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue