(self, container_id)
return status
Execute a Docker container using singularity.
        This is the main method invoked to run a container with singularity.
          * argument: container_id or name
          * options:  many via self.opt see the help
Execute a Docker container using singularity.
        This is the main method invoked to run a container with singularity.
          * argument: container_id or name
          * options:  many via self.opt see the help
Execute a Docker container using singularity . This is the main method invoked to run a container with singularity . * argument : container_id or name * options : many via self . opt see the help
def run(self, container_id):
        """Execute a Docker container using singularity.
        This is the main method invoked to run a container with singularity.
          * argument: container_id or name
          * options:  many via self.opt see the help
        """

        if os.path.isdir(
                FileBind(self.localrepo, container_id).container_orig_dir):
            FileBind(self.localrepo, container_id).restore() # legacy 1.1.3

        Config.conf['sysdirs_list'] = (
            # "/dev", "/proc", "/sys",
            "/etc/resolv.conf", "/etc/host.conf",
            "/lib/modules",
        )

        # setup execution
        exec_path = self._run_init(container_id)
        if not exec_path:
            return 2
        self.opt["cmd"][0] = exec_path.replace(self.container_root + "/", "")

        self._run_invalid_options()

        self._make_container_directories()

        self.select_singularity()

        self._run_as_root()

        # set environment variables
        self._run_env_set()

        if Msg.level >= Msg.DBG:
            singularity_debug = ["--debug", "-v", ]
        elif self._has_option("--silent"):
            singularity_debug = ["--silent", ]
        elif self._has_option("--quiet"):
            singularity_debug = ["--quiet", ]
        else:
            singularity_debug = []

        if self.executable.startswith(self.localrepo.bindir):
            Config.conf['singularity_options'].extend(["-u", ])

        #if FileUtil("nvidia-smi").find_exec():
        #    Config.conf['singularity_options'].extend(["--nv", ])

        singularity_vol_list = self._get_volume_bindings()

        # build the actual command
        self.execution_id = Unique().uuid(self.container_id)
        cmd_l = self._set_cpu_affinity()
        cmd_l.append(self.executable)
        cmd_l.extend(singularity_debug)
        cmd_l.append("exec")
        cmd_l.extend(Config.conf['singularity_options'])
        if self.opt["cwd"]:
            cmd_l.extend(["--pwd", self.opt["cwd"], ])
        cmd_l.extend(singularity_vol_list)
        cmd_l.append(self.container_root)
        cmd_l.extend(self.opt["cmd"])
        Msg().out("CMD =", cmd_l, l=Msg.VER)

        # if not --hostenv clean the environment
        self._run_env_cleanup_dict()

        # execute
        self._run_banner(self.opt["cmd"][0], '/')
        status = subprocess.call(cmd_l, shell=False, close_fds=True, \
            env=os.environ.update(self._singularity_env_get()))
        return status
def run ( self , container_id ) : if os . path . isdir ( FileBind ( self . localrepo , container_id ) . container_orig_dir ) : FileBind ( self . localrepo , container_id ) . restore ( ) # legacy 1.1.3 Config . conf [ 'sysdirs_list' ] = ( # "/dev", "/proc", "/sys", "/etc/resolv.conf" , "/etc/host.conf" , "/lib/modules" , ) # setup execution exec_path = self . _run_init ( container_id ) if not exec_path : return 2 self . opt [ "cmd" ] [ 0 ] = exec_path . replace ( self . container_root + "/" , "" ) self . _run_invalid_options ( ) self . _make_container_directories ( ) self . select_singularity ( ) self . _run_as_root ( ) # set environment variables self . _run_env_set ( ) if Msg . level >= Msg . DBG : singularity_debug = [ "--debug" , "-v" , ] elif self . _has_option ( "--silent" ) : singularity_debug = [ "--silent" , ] elif self . _has_option ( "--quiet" ) : singularity_debug = [ "--quiet" , ] else : singularity_debug = [ ] if self . executable . startswith ( self . localrepo . bindir ) : Config . conf [ 'singularity_options' ] . extend ( [ "-u" , ] ) #if FileUtil("nvidia-smi").find_exec(): #    Config.conf['singularity_options'].extend(["--nv", ]) singularity_vol_list = self . _get_volume_bindings ( ) # build the actual command self . execution_id = Unique ( ) . uuid ( self . container_id ) cmd_l = self . _set_cpu_affinity ( ) cmd_l . append ( self . executable ) cmd_l . extend ( singularity_debug ) cmd_l . append ( "exec" ) cmd_l . extend ( Config . conf [ 'singularity_options' ] ) if self . opt [ "cwd" ] : cmd_l . extend ( [ "--pwd" , self . opt [ "cwd" ] , ] ) cmd_l . extend ( singularity_vol_list ) cmd_l . append ( self . container_root ) cmd_l . extend ( self . opt [ "cmd" ] ) Msg ( ) . out ( "CMD =" , cmd_l , l = Msg . VER ) # if not --hostenv clean the environment self . _run_env_cleanup_dict ( ) # execute self . _run_banner ( self . opt [ "cmd" ] [ 0 ] , '/' ) status = subprocess . call ( cmd_l , shell = False , close_fds = True , env = os . environ . update ( self . _singularity_env_get ( ) ) ) return status