@@ -217,7 +217,7 @@ func (vm *DockerVM) Deploy(ctxt context.Context, ccid ccintf.CCID,
217
217
//Start starts a container using a previously created docker image
218
218
func (vm * DockerVM ) Start (ctxt context.Context , ccid ccintf.CCID ,
219
219
args []string , env []string , filesToUpload map [string ][]byte , builder container.BuildSpecFactory , prelaunchFunc container.PrelaunchFunc ) error {
220
- imageID , err := vm .GetVMName (ccid , formatImageName )
220
+ imageName , err := vm .GetVMName (ccid , formatImageName )
221
221
if err != nil {
222
222
return err
223
223
}
@@ -228,47 +228,47 @@ func (vm *DockerVM) Start(ctxt context.Context, ccid ccintf.CCID,
228
228
return err
229
229
}
230
230
231
- containerID , err := vm .GetVMName (ccid , nil )
231
+ containerName , err := vm .GetVMName (ccid , nil )
232
232
if err != nil {
233
233
return err
234
234
}
235
235
236
236
attachStdout := viper .GetBool ("vm.docker.attachStdout" )
237
237
238
238
//stop,force remove if necessary
239
- dockerLogger .Debugf ("Cleanup container %s" , containerID )
240
- vm .stopInternal (ctxt , client , containerID , 0 , false , false )
239
+ dockerLogger .Debugf ("Cleanup container %s" , containerName )
240
+ vm .stopInternal (ctxt , client , containerName , 0 , false , false )
241
241
242
- dockerLogger .Debugf ("Start container %s" , containerID )
243
- err = vm .createContainer (ctxt , client , imageID , containerID , args , env , attachStdout )
242
+ dockerLogger .Debugf ("Start container %s" , containerName )
243
+ err = vm .createContainer (ctxt , client , imageName , containerName , args , env , attachStdout )
244
244
if err != nil {
245
245
//if image not found try to create image and retry
246
246
if err == docker .ErrNoSuchImage {
247
247
if builder != nil {
248
248
dockerLogger .Debugf ("start-could not find image <%s> (container id <%s>), because of <%s>..." +
249
- "attempt to recreate image" , imageID , containerID , err )
249
+ "attempt to recreate image" , imageName , containerName , err )
250
250
251
251
reader , err1 := builder ()
252
252
if err1 != nil {
253
253
dockerLogger .Errorf ("Error creating image builder for image <%s> (container id <%s>), " +
254
- "because of <%s>" , imageID , containerID , err1 )
254
+ "because of <%s>" , imageName , containerName , err1 )
255
255
}
256
256
257
257
if err1 = vm .deployImage (client , ccid , args , env , reader ); err1 != nil {
258
258
return err1
259
259
}
260
260
261
261
dockerLogger .Debug ("start-recreated image successfully" )
262
- if err1 = vm .createContainer (ctxt , client , imageID , containerID , args , env , attachStdout ); err1 != nil {
262
+ if err1 = vm .createContainer (ctxt , client , imageName , containerName , args , env , attachStdout ); err1 != nil {
263
263
dockerLogger .Errorf ("start-could not recreate container post recreate image: %s" , err1 )
264
264
return err1
265
265
}
266
266
} else {
267
- dockerLogger .Errorf ("start-could not find image <%s>, because of %s" , imageID , err )
267
+ dockerLogger .Errorf ("start-could not find image <%s>, because of %s" , imageName , err )
268
268
return err
269
269
}
270
270
} else {
271
- dockerLogger .Errorf ("start-could not recreate container <%s>, because of %s" , containerID , err )
271
+ dockerLogger .Errorf ("start-could not recreate container <%s>, because of %s" , containerName , err )
272
272
return err
273
273
}
274
274
}
@@ -285,7 +285,7 @@ func (vm *DockerVM) Start(ctxt context.Context, ccid ccintf.CCID,
285
285
// The returned error is not used outside the scope of this function. Assign the
286
286
// error to a local variable to prevent clobbering the function variable 'err'.
287
287
err := client .AttachToContainer (docker.AttachToContainerOptions {
288
- Container : containerID ,
288
+ Container : containerName ,
289
289
OutputStream : w ,
290
290
ErrorStream : w ,
291
291
Logs : true ,
@@ -306,7 +306,7 @@ func (vm *DockerVM) Start(ctxt context.Context, ccid ccintf.CCID,
306
306
case <- attached :
307
307
// successful attach
308
308
case <- time .After (10 * time .Second ):
309
- dockerLogger .Errorf ("Timeout while attaching to IO channel in container %s" , containerID )
309
+ dockerLogger .Errorf ("Timeout while attaching to IO channel in container %s" , containerName )
310
310
return
311
311
}
312
312
@@ -320,8 +320,8 @@ func (vm *DockerVM) Start(ctxt context.Context, ccid ccintf.CCID,
320
320
is := bufio .NewReader (r )
321
321
322
322
// Acquire a custom logger for our chaincode, inheriting the level from the peer
323
- containerLogger := flogging .MustGetLogger (containerID )
324
- logging .SetLevel (logging .GetLevel ("peer" ), containerID )
323
+ containerLogger := flogging .MustGetLogger (containerName )
324
+ logging .SetLevel (logging .GetLevel ("peer" ), containerName )
325
325
326
326
for {
327
327
// Loop forever dumping lines of text into the containerLogger
@@ -330,7 +330,7 @@ func (vm *DockerVM) Start(ctxt context.Context, ccid ccintf.CCID,
330
330
if err2 != nil {
331
331
switch err2 {
332
332
case io .EOF :
333
- dockerLogger .Infof ("Container %s has closed its IO channel" , containerID )
333
+ dockerLogger .Infof ("Container %s has closed its IO channel" , containerName )
334
334
default :
335
335
dockerLogger .Errorf ("Error reading container output: %s" , err2 )
336
336
}
@@ -363,14 +363,14 @@ func (vm *DockerVM) Start(ctxt context.Context, ccid ccintf.CCID,
363
363
364
364
gw .Close ()
365
365
366
- err = client .UploadToContainer (containerID , docker.UploadToContainerOptions {
366
+ err = client .UploadToContainer (containerName , docker.UploadToContainerOptions {
367
367
InputStream : bytes .NewReader (payload .Bytes ()),
368
368
Path : "/" ,
369
369
NoOverwriteDirNonDir : false ,
370
370
})
371
371
372
372
if err != nil {
373
- return fmt .Errorf ("Error uploading files to the container instance %s: %s" , containerID , err )
373
+ return fmt .Errorf ("Error uploading files to the container instance %s: %s" , containerName , err )
374
374
}
375
375
}
376
376
@@ -381,13 +381,13 @@ func (vm *DockerVM) Start(ctxt context.Context, ccid ccintf.CCID,
381
381
}
382
382
383
383
// start container with HostConfig was deprecated since v1.10 and removed in v1.2
384
- err = client .StartContainer (containerID , nil )
384
+ err = client .StartContainer (containerName , nil )
385
385
if err != nil {
386
386
dockerLogger .Errorf ("start-could not start container: %s" , err )
387
387
return err
388
388
}
389
389
390
- dockerLogger .Debugf ("Started container %s" , containerID )
390
+ dockerLogger .Debugf ("Started container %s" , containerName )
391
391
return nil
392
392
}
393
393
0 commit comments