(self, cmdp)
return exit_status
run: execute a container
        run [options] <container-id-or-name>
        run [options] <repo/image:tag>
        --rm                       :delete container upon exit
        --workdir=/home/userXX     :working directory set to /home/userXX
        --user=userXX              :run as userXX
        --user=root                :run as root
        --volume=/data:/mnt        :mount host directory /data in /mnt
        --novol=/proc              :remove /proc from list of volumes to mount
        --env="MYTAG=xxx"          :set environment variable
        --env-file=<file>          :read environment variables from file
        --hostauth                 :get user account and group from host
        --containerauth            :use container passwd and group directly
        --nosysdirs                :do not bind the host /proc /sys /run /dev
        --nometa                   :ignore container metadata
        --dri                      :bind directories relevant for dri graphics
        --hostenv                  :pass the host environment to the container
        --cpuset-cpus=<1,2,3-4>    :CPUs in which to allow execution
        --name=<container-name>    :set or change the name of the container
        --bindhome                 :bind the home directory into the container
        --kernel=<kernel-id>       :simulate this Linux kernel version
        --device=/dev/xxx          :pass device to container (R1 mode only)
        --location=<container-dir> :use container outside the repository
        --nobanner                 :don't print a startup banner
        --entrypoint               :override the container metadata entrypoint

        Only available in Rn execution modes:
        --device=/dev/xxx          :pass device to container (R1 mode only)

        Only available in Pn execution modes:
        --publish=<hport:cport>    :map container TCP/IP <cport> into <hport>
        --publish-all              :bind and connect to random ports

        run <container-id-or-name> executes an existing container, previously
        created from an image by using: create <repo/image:tag>

        run <repo/image:tag> always creates a new container from the image
        if needed the image is pulled. This is slow and may waste storage.
run: execute a container
        run [options] <container-id-or-name>
        run [options] <repo/image:tag>
        --rm                       :delete container upon exit
        --workdir=/home/userXX     :working directory set to /home/userXX
        --user=userXX              :run as userXX
        --user=root                :run as root
        --volume=/data:/mnt        :mount host directory /data in /mnt
        --novol=/proc              :remove /proc from list of volumes to mount
        --env="MYTAG=xxx"          :set environment variable
        --env-file=<file>          :read environment variables from file
        --hostauth                 :get user account and group from host
        --containerauth            :use container passwd and group directly
        --nosysdirs                :do not bind the host /proc /sys /run /dev
        --nometa                   :ignore container metadata
        --dri                      :bind directories relevant for dri graphics
        --hostenv                  :pass the host environment to the container
        --cpuset-cpus=<1,2,3-4>    :CPUs in which to allow execution
        --name=<container-name>    :set or change the name of the container
        --bindhome                 :bind the home directory into the container
        --kernel=<kernel-id>       :simulate this Linux kernel version
        --device=/dev/xxx          :pass device to container (R1 mode only)
        --location=<container-dir> :use container outside the repository
        --nobanner                 :don't print a startup banner
        --entrypoint               :override the container metadata entrypoint
run : execute a container run [ options ] <container - id - or - name > run [ options ] <repo / image : tag > -- rm : delete container upon exit -- workdir = / home / userXX : working directory set to / home / userXX -- user = userXX : run as userXX -- user = root : run as root -- volume = / data : / mnt : mount host directory / data in / mnt -- novol = / proc : remove / proc from list of volumes to mount -- env = MYTAG = xxx : set environment variable -- env - file = <file > : read environment variables from file -- hostauth : get user account and group from host -- containerauth : use container passwd and group directly -- nosysdirs : do not bind the host / proc / sys / run / dev -- nometa : ignore container metadata -- dri : bind directories relevant for dri graphics -- hostenv : pass the host environment to the container -- cpuset - cpus = <1 2 3 - 4 > : CPUs in which to allow execution -- name = <container - name > : set or change the name of the container -- bindhome : bind the home directory into the container -- kernel = <kernel - id > : simulate this Linux kernel version -- device = / dev / xxx : pass device to container ( R1 mode only ) -- location = <container - dir > : use container outside the repository -- nobanner : don t print a startup banner -- entrypoint : override the container metadata entrypoint
def do_run(self, cmdp):
        """
        run: execute a container
        run [options] <container-id-or-name>
        run [options] <repo/image:tag>
        --rm                       :delete container upon exit
        --workdir=/home/userXX     :working directory set to /home/userXX
        --user=userXX              :run as userXX
        --user=root                :run as root
        --volume=/data:/mnt        :mount host directory /data in /mnt
        --novol=/proc              :remove /proc from list of volumes to mount
        --env="MYTAG=xxx"          :set environment variable
        --env-file=<file>          :read environment variables from file
        --hostauth                 :get user account and group from host
        --containerauth            :use container passwd and group directly
        --nosysdirs                :do not bind the host /proc /sys /run /dev
        --nometa                   :ignore container metadata
        --dri                      :bind directories relevant for dri graphics
        --hostenv                  :pass the host environment to the container
        --cpuset-cpus=<1,2,3-4>    :CPUs in which to allow execution
        --name=<container-name>    :set or change the name of the container
        --bindhome                 :bind the home directory into the container
        --kernel=<kernel-id>       :simulate this Linux kernel version
        --device=/dev/xxx          :pass device to container (R1 mode only)
        --location=<container-dir> :use container outside the repository
        --nobanner                 :don't print a startup banner
        --entrypoint               :override the container metadata entrypoint

        Only available in Rn execution modes:
        --device=/dev/xxx          :pass device to container (R1 mode only)

        Only available in Pn execution modes:
        --publish=<hport:cport>    :map container TCP/IP <cport> into <hport>
        --publish-all              :bind and connect to random ports

        run <container-id-or-name> executes an existing container, previously
        created from an image by using: create <repo/image:tag>

        run <repo/image:tag> always creates a new container from the image
        if needed the image is pulled. This is slow and may waste storage.
        """
        self._get_run_options(cmdp)
        container_or_image = cmdp.get("P1")
        Config.conf['location'] = cmdp.get("--location=")
        delete = cmdp.get("--rm")
        name = cmdp.get("--name=")
        #
        if cmdp.missing_options(): # syntax error
            return self.STATUS_ERROR

        if Config.conf['location']:
            container_id = ""
        elif not container_or_image:
            Msg().err("Error: must specify container_id or image:tag")
            return self.STATUS_ERROR
        else:
            container_id = self.localrepo.get_container_id(container_or_image)
            if not container_id:
                (imagerepo, tag) = self._check_imagespec(container_or_image)
                if (imagerepo and
                        self.localrepo.cd_imagerepo(imagerepo, tag)):
                    container_id = self._create(imagerepo + ":" + tag)
                if not container_id:
                    self.do_pull(cmdp)
                    if self.localrepo.cd_imagerepo(imagerepo, tag):
                        container_id = self._create(imagerepo + ":" + tag)
                    if not container_id:
                        Msg().err("Error: image or container not available")
                        return self.STATUS_ERROR
            if name and container_id:
                if not self.localrepo.set_container_name(container_id, name):
                    Msg().err("Error: invalid container name format")
                    return self.STATUS_ERROR

        exec_mode = ExecutionMode(self.localrepo, container_id)
        exec_engine = exec_mode.get_engine()
        if not exec_engine:
            Msg().err("Error: no execution engine for this execmode")
            return self.STATUS_ERROR

        self._get_run_options(cmdp, exec_engine)
        exit_status = exec_engine.run(container_id)
        if delete and not self.localrepo.isprotected_container(container_id):
            self.localrepo.del_container(container_id)

        return exit_status
def do_run ( self , cmdp ) : self . _get_run_options ( cmdp ) container_or_image = cmdp . get ( "P1" ) Config . conf [ 'location' ] = cmdp . get ( "--location=" ) delete = cmdp . get ( "--rm" ) name = cmdp . get ( "--name=" ) # if cmdp . missing_options ( ) : # syntax error return self . STATUS_ERROR if Config . conf [ 'location' ] : container_id = "" elif not container_or_image : Msg ( ) . err ( "Error: must specify container_id or image:tag" ) return self . STATUS_ERROR else : container_id = self . localrepo . get_container_id ( container_or_image ) if not container_id : ( imagerepo , tag ) = self . _check_imagespec ( container_or_image ) if ( imagerepo and self . localrepo . cd_imagerepo ( imagerepo , tag ) ) : container_id = self . _create ( imagerepo + ":" + tag ) if not container_id : self . do_pull ( cmdp ) if self . localrepo . cd_imagerepo ( imagerepo , tag ) : container_id = self . _create ( imagerepo + ":" + tag ) if not container_id : Msg ( ) . err ( "Error: image or container not available" ) return self . STATUS_ERROR if name and container_id : if not self . localrepo . set_container_name ( container_id , name ) : Msg ( ) . err ( "Error: invalid container name format" ) return self . STATUS_ERROR exec_mode = ExecutionMode ( self . localrepo , container_id ) exec_engine = exec_mode . get_engine ( ) if not exec_engine : Msg ( ) . err ( "Error: no execution engine for this execmode" ) return self . STATUS_ERROR self . _get_run_options ( cmdp , exec_engine ) exit_status = exec_engine . run ( container_id ) if delete and not self . localrepo . isprotected_container ( container_id ) : self . localrepo . del_container ( container_id ) return exit_status