repo2docker/app.py
def start_container(self):
        """Start docker container from built image

        Returns running container
        """
        client = docker.from_env(version='auto')

        docker_host = os.environ.get('DOCKER_HOST')
        if docker_host:
            host_name = urlparse(docker_host).hostname
        else:
            host_name = '127.0.0.1'
        self.hostname = host_name

        if not self.run_cmd:
            port = str(self._get_free_port())
            self.port = port
            # To use the option --NotebookApp.custom_display_url
            # make sure the base-notebook image is updated:
            # docker pull jupyter/base-notebook
            run_cmd = [
                'jupyter', 'notebook',
                '--ip', '0.0.0.0',
                '--port', port,
                "--NotebookApp.custom_display_url=http://{}:{}".format(host_name, port),
            ]
            ports = {'%s/tcp' % port: port}
        else:
            # run_cmd given by user, if port is also given then pass it on
            run_cmd = self.run_cmd
            if self.ports:
                ports = self.ports
            else:
                ports = {}
        # store ports on self so they can be retrieved in tests
        self.ports = ports

        container_volumes = {}
        if self.volumes:
            api_client = docker.APIClient(
                version='auto',
                **docker.utils.kwargs_from_env()
            )
            image = api_client.inspect_image(self.output_image_spec)
            image_workdir = image['ContainerConfig']['WorkingDir']

            for k, v in self.volumes.items():
                container_volumes[os.path.abspath(k)] = {
                    'bind': v if v.startswith('/') else os.path.join(image_workdir, v),
                    'mode': 'rw'
                }

        container = client.containers.run(
            self.output_image_spec,
            publish_all_ports=self.all_ports,
            ports=ports,
            detach=True,
            command=run_cmd,
            volumes=container_volumes,
            environment=self.environment
        )
        while container.status == 'created':
            time.sleep(0.5)
            container.reload()

        return container
Start docker container from built image

        Returns running container
        
Start docker container from built image
Returns running container
Start docker container from built image Returns running container
def start_container(self):
        client = docker.from_env(version='auto')
        docker_host = os.environ.get('DOCKER_HOST')
        if docker_host:
            host_name = urlparse(docker_host).hostname
        else:
            host_name = '127.0.0.1'
        self.hostname = host_name
        if not self.run_cmd:
            port = str(self._get_free_port())
            self.port = port
            run_cmd = [
                'jupyter', 'notebook',
                '--ip', '0.0.0.0',
                '--port', port,
                "--NotebookApp.custom_display_url=http://{}:{}".format(host_name, port),
            ]
            ports = {'%s/tcp' % port: port}
        else:
            run_cmd = self.run_cmd
            if self.ports:
                ports = self.ports
            else:
                ports = {}
        self.ports = ports
        container_volumes = {}
        if self.volumes:
            api_client = docker.APIClient(
                version='auto',
                **docker.utils.kwargs_from_env()
            )
            image = api_client.inspect_image(self.output_image_spec)
            image_workdir = image['ContainerConfig']['WorkingDir']
            for k, v in self.volumes.items():
                container_volumes[os.path.abspath(k)] = {
                    'bind': v if v.startswith('/') else os.path.join(image_workdir, v),
                    'mode': 'rw'
                }
        container = client.containers.run(
            self.output_image_spec,
            publish_all_ports=self.all_ports,
            ports=ports,
            detach=True,
            command=run_cmd,
            volumes=container_volumes,
            environment=self.environment
        )
        while container.status == 'created':
            time.sleep(0.5)
            container.reload()
        return container
def start_container ( self ) : client = docker . from_env ( version = 'auto' ) docker_host = os . environ . get ( 'DOCKER_HOST' ) if docker_host : host_name = urlparse ( docker_host ) . hostname else : host_name = '127.0.0.1' self . hostname = host_name if not self . run_cmd : port = str ( self . _get_free_port ( ) ) self . port = port run_cmd = [ 'jupyter' , 'notebook' , '--ip' , '0.0.0.0' , '--port' , port , "--NotebookApp.custom_display_url=http://{}:{}" . format ( host_name , port ) , ] ports = { '%s/tcp' % port : port } else : run_cmd = self . run_cmd if self . ports : ports = self . ports else : ports = { } self . ports = ports container_volumes = { } if self . volumes : api_client = docker . APIClient ( version = 'auto' , ** docker . utils . kwargs_from_env ( ) ) image = api_client . inspect_image ( self . output_image_spec ) image_workdir = image [ 'ContainerConfig' ] [ 'WorkingDir' ] for k , v in self . volumes . items ( ) : container_volumes [ os . path . abspath ( k ) ] = { 'bind' : v if v . startswith ( '/' ) else os . path . join ( image_workdir , v ) , 'mode' : 'rw' } container = client . containers . run ( self . output_image_spec , publish_all_ports = self . all_ports , ports = ports , detach = True , command = run_cmd , volumes = container_volumes , environment = self . environment ) while container . status == 'created' : time . sleep ( 0.5 ) container . reload ( ) return container
Start docker container from built image
Returns running container
Start docker container from built image Returns running container
"""Start docker container from built image

        Returns running container
        """ # To use the option --NotebookApp.custom_display_url # make sure the base-notebook image is updated: # docker pull jupyter/base-notebook # run_cmd given by user, if port is also given then pass it on # store ports on self so they can be retrieved in tests
self