def get_container_root(container):
 default_path = os.path.join('/var/lib/docker', 'containers', _get_container_infos(container)['Id'])
 default_rootfs = os.path.join(default_path, 'rootfs')
 rootfs_re = re.compile('^lxc.rootfs\\s*=\\s*(.*)\\s*$', re.U)
 try:
  lxcconfig = os.path.join(default_path, 'config.lxc')
  with salt.utils.fopen(lxcconfig) as fhr:
   lines = fhr.readlines()
   rlines = lines[:]
   rlines.reverse()
   for rline in rlines:
    robj = rootfs_re.search(rline)
    if robj:
     rootfs = robj.groups()[0]
     break
 except Exception:
  rootfs = default_rootfs
 return rootfs

def get_container_root ( container ) : default_path = os . path . join ( '/var/lib/docker' , 'containers' , _get_container_infos ( container ) [ 'Id' ] ) default_rootfs = os . path . join ( default_path , 'rootfs' ) rootfs_re = re . compile ( '^lxc.rootfs\\s*=\\s*(.*)\\s*$' , re . U ) try : lxcconfig = os . path . join ( default_path , 'config.lxc' ) with salt . utils . fopen ( lxcconfig ) as fhr : lines = fhr . readlines ( ) rlines = lines [ : ] rlines . reverse ( ) for rline in rlines : robj = rootfs_re . search ( rline ) if robj : rootfs = robj . groups ( ) [ 0 ] break except Exception : rootfs = default_rootfs return rootfs
get the container rootfs path container container id or grain cli example: .