@@ -194,28 +194,34 @@ export default class DockerService {
194
194
) ;
195
195
containerConfig . HostConfig . Binds = binds ;
196
196
197
- // Restart the container with the new image
198
- await container . stop ( ) ;
199
- await container . remove ( ) ;
200
- const newContainer = await DockerService . docker . createContainer ( containerConfig ) ;
201
- await newContainer . start ( ) ;
202
-
203
- // Remove old image
204
- DockerService . docker
205
- . getImage ( oldImageId )
206
- . remove ( { force : true } , ( err , data ) => {
207
- if ( err ) {
208
- logger . error ( "Error removing old image: " + err ) ;
209
- } else {
210
- logger . info ( "Old image removed successfully" ) ;
211
- }
212
- } ) ;
213
-
214
- // Publish final 100% progress
215
- await HomeassistantService . publishUpdateProgressMessage ( info , mqttClient , 100 , false ) ;
216
- this . updatingContainers = this . updatingContainers . filter ( ( id ) => id !== containerId ) ;
217
-
218
- return newContainer ;
197
+ try {
198
+ // Restart the container with the new image
199
+ await container . stop ( ) ;
200
+ await container . remove ( ) ;
201
+ const newContainer = await DockerService . docker . createContainer ( containerConfig ) ;
202
+ await newContainer . start ( ) ;
203
+
204
+ // Remove old image
205
+ DockerService . docker
206
+ . getImage ( oldImageId )
207
+ . remove ( { force : true } , ( err , data ) => {
208
+ if ( err ) {
209
+ logger . error ( "Error removing old image: " + err ) ;
210
+ } else {
211
+ logger . info ( "Old image removed successfully" ) ;
212
+ }
213
+ } ) ;
214
+
215
+ // Publish final 100% progress
216
+ await HomeassistantService . publishUpdateProgressMessage ( info , mqttClient , 100 , false ) ;
217
+ this . updatingContainers = this . updatingContainers . filter ( ( id ) => id !== containerId ) ;
218
+
219
+ return newContainer ;
220
+ } catch ( error ) {
221
+ logger . error ( "Error restarting container with new image" ) ;
222
+ logger . error ( error ) ;
223
+ throw error ;
224
+ }
219
225
} ,
220
226
( event ) => {
221
227
logger . debug ( `Status: ${ event . status } ` ) ;
0 commit comments