

def getContainerDetails(container):
    ip = 'N/A'
    if container.state().network != None and container.state().network.get('eth0') != None:
        if len(container.state().network.get('eth0')['addresses']) > 0:
            ip = container.state().network['eth0']['addresses'][0].get('address', 'N/A')

    return {
        'name': container.name,
        'status': container.status,
        'ip': ip,
        'ephemeral': container.ephemeral,
        'image': ''.join(container.config.get('image.os') + ' ' + container.config.get('image.release') + ' ' + container.config.get('image.architecture')),
        'created_at': container.created_at
    }


def getContainerDetails(container):
    ip = 'N/A'
    if container.state().network != None and container.state().network.get('eth0') != None:
        if len(container.state().network.get('eth0')['addresses']) > 0:
            ip = container.state().network['eth0']['addresses'][0].get('address', 'N/A')

    image = 'N/A'
    if container.config.get('image.os') != None and container.config.get('image.release') != None and container.config.get('image.architecture') != None:
        image = ''.join(container.config.get('image.os') + ' ' + container.config.get('image.release') + ' ' + container.config.get('image.architecture'))

    return {
        'name': container.name,
        'status': container.status,
        'ip': ip,
        'ephemeral': container.ephemeral,
        'image': image,
        'created_at': container.created_at
    }
Fix container list bug when missing image
Fix container list bug when missing image

  
  
  def getContainerDetails(container):
      ip = 'N/A'
      if container.state().network != None and container.state().network.get('eth0') != None:
          if len(container.state().network.get('eth0')['addresses']) > 0:
              ip = container.state().network['eth0']['addresses'][0].get('address', 'N/A')
  
+     image = 'N/A'
+     if container.config.get('image.os') != None and container.config.get('image.release') != None and container.config.get('image.architecture') != None:
+         image = ''.join(container.config.get('image.os') + ' ' + container.config.get('image.release') + ' ' + container.config.get('image.architecture'))
+ 
      return {
          'name': container.name,
          'status': container.status,
          'ip': ip,
          'ephemeral': container.ephemeral,
-         'image': ''.join(container.config.get('image.os') + ' ' + container.config.get('image.release') + ' ' + container.config.get('image.architecture')),
+         'image': image,
          'created_at': container.created_at
      }
Fix container list bug when missing image
## Code Before:


def getContainerDetails(container):
    ip = 'N/A'
    if container.state().network != None and container.state().network.get('eth0') != None:
        if len(container.state().network.get('eth0')['addresses']) > 0:
            ip = container.state().network['eth0']['addresses'][0].get('address', 'N/A')

    return {
        'name': container.name,
        'status': container.status,
        'ip': ip,
        'ephemeral': container.ephemeral,
        'image': ''.join(container.config.get('image.os') + ' ' + container.config.get('image.release') + ' ' + container.config.get('image.architecture')),
        'created_at': container.created_at
    }
## Instruction:
Fix container list bug when missing image
## Code After:


def getContainerDetails(container):
    ip = 'N/A'
    if container.state().network != None and container.state().network.get('eth0') != None:
        if len(container.state().network.get('eth0')['addresses']) > 0:
            ip = container.state().network['eth0']['addresses'][0].get('address', 'N/A')

    image = 'N/A'
    if container.config.get('image.os') != None and container.config.get('image.release') != None and container.config.get('image.architecture') != None:
        image = ''.join(container.config.get('image.os') + ' ' + container.config.get('image.release') + ' ' + container.config.get('image.architecture'))

    return {
        'name': container.name,
        'status': container.status,
        'ip': ip,
        'ephemeral': container.ephemeral,
        'image': image,
        'created_at': container.created_at
    }