(self, imagerepo, tag, layer_file, container_json)
return self.container_id
Create a container from a layer file exported by Docker.
Create a container from a layer file exported by Docker.
Create a container from a layer file exported by Docker .
def create_fromlayer(self, imagerepo, tag, layer_file, container_json):
        """Create a container from a layer file exported by Docker.
        """
        self.imagerepo = imagerepo
        self.tag = tag
        if not self.container_id:
            self.container_id = Unique().uuid(os.path.basename(self.imagerepo))

        if not container_json:
            Msg().err("Error: create container: getting json")
            return False

        container_dir = self.localrepo.setup_container(
            self.imagerepo, self.tag, self.container_id)
        if not container_dir:
            Msg().err("Error: create container: setting up")
            return False

        fjson = container_dir + "/container.json"
        self.localrepo.save_json(fjson, container_json)
        status = self._untar_layers([layer_file, ], container_dir + "/ROOT")
        if not status:
            Msg().err("Error: creating container:", self.container_id)
        elif not self._chk_container_root():
            Msg().out("Warning: check container content:", self.container_id,
                      l=Msg.WAR)

        return self.container_id
def create_fromlayer ( self , imagerepo , tag , layer_file , container_json ) : self . imagerepo = imagerepo self . tag = tag if not self . container_id : self . container_id = Unique ( ) . uuid ( os . path . basename ( self . imagerepo ) ) if not container_json : Msg ( ) . err ( "Error: create container: getting json" ) return False container_dir = self . localrepo . setup_container ( self . imagerepo , self . tag , self . container_id ) if not container_dir : Msg ( ) . err ( "Error: create container: setting up" ) return False fjson = container_dir + "/container.json" self . localrepo . save_json ( fjson , container_json ) status = self . _untar_layers ( [ layer_file , ] , container_dir + "/ROOT" ) if not status : Msg ( ) . err ( "Error: creating container:" , self . container_id ) elif not self . _chk_container_root ( ) : Msg ( ) . out ( "Warning: check container content:" , self . container_id , l = Msg . WAR ) return self . container_id