Creator function for creating an instance of a Docker image script.
173499
def creator(entry, config):
        """"""
        # writing Dockerfile
        dockerfile = render(config.script, model=config.model, env=config.env,
                            variables=config.variables, item=config.item)
        filename = "dockerfile.dry.run.see.comment"

        if not config.dry_run:
            temp = tempfile.NamedTemporaryFile(
                prefix="dockerfile-", mode='w+t', delete=False)
            temp.writelines(dockerfile)
            temp.close()
            filename = temp.name
            dockerfile = ''

        # rendering the Bash script for generating the Docker image
        name = entry['name'] + "-%s" % os.getpid() if entry['unique'] else entry['name']
        tag = render(entry['tag'], model=config.model, env=config.env, item=config.item)
        template_file = os.path.join(os.path.dirname(__file__), 'templates/docker-image.sh.j2')

        with open(template_file) as handle:
            template = handle.read()
            config.script = render(template, name=name, tag=tag,
                                   dockerfile_content=dockerfile,
                                   dockerfile_filename=filename)

        return Image(config)
387081
function(opts) {

    // Get docker config.
    return dockerConfigInstance(opts)
    // Initalize a dockerode object.
    .then(function(engineConfig) {
      return new Dockerode(engineConfig);
    })
    // Wrap errors.
    .catch(function(err) {
      throw new VError(err, 'Error initializing docker.');
    });

  }
493242
def create(self, create_missing=None):
        
        return DockerComputeResource(
            self._server_config,
            id=self.create_json(create_missing)['id'],
        ).read()
1355433
def create(self, width=0, depth=0, path=None, flags=0, seed=0):
        
        return self.create_method(self, width, depth, path, flags, seed)
528420
def create(client, _type, **kwargs):
    """"""
    obj = client.factory.create("ns0:%s" % _type)
    for key, value in kwargs.items():
        setattr(obj, key, value)
    return obj
43560
def gen_scripts(
    file_name, file_name_ext, obj_name, obj_ext_name, output, output_ext,
    field=1, notexplicit=None, ascii_props=False, append=False, prefix=""
):
    """"""

    obj = {}
    obj2 = {}
    aliases = {}
    with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, 'PropertyValueAliases.txt'), 'r', 'utf-8') as uf:
        for line in uf:
            if line.startswith('sc ;'):
                values = line.split(';')
                aliases[format_name(values[1].strip())] = format_name(values[2].strip())

    with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, file_name_ext), 'r', 'utf-8') as uf:
        for line in uf:
            if not line.startswith('#'):
                data = line.split('#')[0].split(';')
                if len(data) < 2:
                    continue
                exts = [aliases[format_name(n)] for n in data[1].strip().split(' ')]
                span = create_span([int(i, 16) for i in data[0].strip().split('..')], is_bytes=ascii_props)
                for ext in exts:
                    if ext not in obj2:
                        obj2[ext] = []
                    if span is None:
                        continue

                    obj2[ext].extend(span)

    with codecs.open(os.path.join(HOME, 'unicodedata', UNIVERSION, file_name), 'r', 'utf-8') as uf:
        for line in uf:
            if not line.startswith('#'):
                data = line.split('#')[0].split(';')
                if len(data) < 2:
                    continue
                span = create_span([int(i, 16) for i in data[0].strip().split('..')], is_bytes=ascii_props)
                name = format_name(data[1])
                if name not in obj:
                    obj[name] = []
                if name not in obj2:
                    obj2[name] = []

                if span is None:
                    continue

                obj[name].extend(span)
                obj2[name].extend(span)

    for name in list(obj.keys()):
        s = set(obj[name])
        obj[name] = sorted(s)

    for name in list(obj2.keys()):
        s = set(obj2[name])
        obj2[name] = sorted(s)

    if notexplicit:
        not_explicitly_defined(obj, notexplicit, is_bytes=ascii_props)
        not_explicitly_defined(obj2, notexplicit, is_bytes=ascii_props)

    # Convert characters values to ranges
    char2range(obj, is_bytes=ascii_props)
    char2range(obj2, is_bytes=ascii_props)

    with codecs.open(output, 'a' if append else 'w', 'utf-8') as f:
        if not append:
            f.write(HEADER)
        # Write out the Unicode properties
        f.write('%s_%s = {\n' % (prefix, obj_name))
        count = len(obj) - 1
        i = 0
        for k1, v1 in sorted(obj.items()):
            f.write('    "%s": "%s"' % (k1, v1))
            if i == count:
                f.write('\n}\n')
            else:
                f.write(',\n')
            i += 1

    with codecs.open(output_ext, 'a' if append else 'w', 'utf-8') as f:
        if not append:
            f.write(HEADER)
        # Write out the Unicode properties
        f.write('%s_%s = {\n' % (prefix, obj_ext_name))
        count = len(obj2) - 1
        i = 0
        for k1, v1 in sorted(obj2.items()):
            f.write('    "%s": "%s"' % (k1, v1))
            if i == count:
                f.write('\n}\n')
            else:
                f.write(',\n')
            i += 1
474555
def __create_image(self, inpt, hashfun):
        """"""
        if hashfun not in generator.HASHES.keys():
            print ("Unknown or unsupported hash function. Using default: %s"
                   % self.DEFAULT_HASHFUN)
            algo = self.DEFAULT_HASHFUN
        else:
            algo = hashfun
        return generator.generate(inpt, algo)
704951
def create(name, image, bare):
    
    if bool(bare) == bool(image):
        raise click.UsageError("Specify either --bare or image using --image.")

    path = get_project_path(name)

    print("Creating %s..." % path)
    try:
        os.mkdir(path)
    except FileExistsError:
        die("%s already exists." % path)

    if not bare:
        print("Creating container with image %s..." % image)
        client = docker.Client()
        try:
            client.create_container(
                image=image,
                name=get_container_name(name),
                hostname=name,
                working_dir='/code/',
                command='tail -f /dev/null',
                tty=True,
                volumes=['/code/'],
                host_config=client.create_host_config(binds={
                    path: {'bind': '/code/', 'mode': 'rw'}
                })
            )
        except docker.errors.APIError as error:
            die(error.explanation.decode())

    enter_project(name)
684585
def makefile(self, mode='r', bufsize=-1):
        
        return _fileobject(Socket(
            _sock=self._fd._sock, 
            _timeout=self._timeout, 
            _proactor_added=self._proactor_added
        ), mode, bufsize)
1157883
def create_shipfile(target, source, env):
    """"""

    source_dir = os.path.dirname(str(source[0]))
    recipe_name = os.path.basename(str(source[0]))[:-5]

    resman = RecipeManager()

    resman.add_recipe_actions(env['CUSTOM_STEPS'])
    resman.add_recipe_folder(source_dir, whitelist=[os.path.basename(str(source[0]))])
    recipe = resman.get_recipe(recipe_name)

    recipe.archive(str(target[0]))
1168823
def make(cls, language=None, extlangs=None, script=None,
             region=None, variants=None, extensions=None, private=None):
        
        values = (language, tuple(extlangs or ()), script, region,
                  tuple(variants or ()), tuple(extensions or ()), private)
        if values in cls._INSTANCES:
            return cls._INSTANCES[values]

        instance = cls(
            language=language, extlangs=extlangs,
            script=script, region=region, variants=variants,
            extensions=extensions, private=private
        )
        cls._INSTANCES[values] = instance
        return instance
1082589
def create(self):
        
        data = self._node_data()
        data["node_id"] = self._id
        if self._node_type == "docker":
            timeout = None
        else:
            timeout = 1200
        trial = 0
        while trial != 6:
            try:
                response = yield from self._compute.post("/projects/{}/{}/nodes".format(self._project.id, self._node_type), data=data, timeout=timeout)
            except ComputeConflict as e:
                if e.response.get("exception") == "ImageMissingError":
                    res = yield from self._upload_missing_image(self._node_type, e.response["image"])
                    if not res:
                        raise e
                else:
                    raise e
            else:
                yield from self.parse_node_response(response.json)
                return True
            trial += 1
597996
def make_script(self):
        """"""
        self.script_path.write(self.script)
        self.script_path.permissions.make_executable()
        return self.script_path
17580
def make_image(opts={})
      opts = {:volume       => '/',
              :size         => 6000,
              :destination  => '/mnt/bundle',
              :exclude      => nil
              }.merge(opts)
      image_file = File.join(opts[:destination], opts[:prefix] )
      cmds = ["mkdir -p #{opts[:destination]}"]
      cmds << "dd if=/dev/zero of=#{image_file} bs=1M count=#{opts[:size]}"
      cmds << "mkfs.ext3 -F -j #{image_file}"
      cmds << "mkdir -p #{opts[:destination]}/loop"
      cmds << "mount -o loop #{image_file} #{opts[:destination]}/loop"
      cmds << "rsync -ax #{rsync_excludes(opts[:exclude])} #{opts[:volume]}/ #{opts[:destination]}/loop/"
      cmds << "if [[ -f /etc/init.d/ec2-ssh-host-key-gen ]]; then chmod u+x /etc/init.d/ec2-ssh-host-key-gen ;fi"
      cmds << "umount #{opts[:destination]}/loop"
      self.ssh cmds
      image_file
    end
286505
def create_container(self, conf, detach, tty):
        """"""

        name = conf.name
        image_name = conf.image_name
        if conf.tag is not NotSpecified:
            image_name = conf.image_name_with_tag
        container_name = conf.container_name

        with conf.assumed_role():
            env = dict(e.pair for e in conf.env)

        binds = conf.volumes.binds
        command = conf.formatted_command
        volume_names = conf.volumes.volume_names
        volumes_from = list(conf.volumes.share_with_names)
        no_tty_option = conf.no_tty_option

        ports = [p.container_port.port_pair for p in conf.ports]
        port_bindings = self.exposed(conf.ports)

        uncreated = []
        for name in binds:
            if not os.path.exists(name):
                log.info("Making volume for mounting\tvolume=%s", name)
                try:
                    os.makedirs(name)
                except OSError as error:
                    uncreated.append((name, error))
        if uncreated:
            raise BadOption("Failed to create some volumes on the host", uncreated=uncreated)

        log.info("Creating container from %s\timage=%s\tcontainer_name=%s\ttty=%s", image_name, name, container_name, tty)
        if binds:
            log.info("\tUsing volumes\tvolumes=%s", volume_names)
        if env:
            log.info("\tUsing environment\tenv=%s", sorted(env.keys()))
        if ports:
            log.info("\tUsing ports\tports=%s", ports)
        if port_bindings:
            log.info("\tPort bindings: %s", port_bindings)
        if volumes_from:
            log.info("\tVolumes from: %s", volumes_from)

        host_config = conf.harpoon.docker_api.create_host_config(
              binds = binds
            , volumes_from = volumes_from
            , port_bindings = port_bindings

            , devices = conf.devices
            , lxc_conf = conf.lxc_conf
            , privileged = conf.privileged
            , restart_policy = conf.restart_policy

            , dns = conf.network.dns
            , dns_search = conf.network.dns_search
            , extra_hosts = conf.network.extra_hosts
            , network_mode = conf.network.network_mode
            , publish_all_ports = conf.network.publish_all_ports

            , cap_add = conf.cpu.cap_add
            , cap_drop = conf.cpu.cap_drop
            , mem_limit = conf.cpu.mem_limit
            , cpu_shares = conf.cpu.cpu_shares
            , cpuset_cpus = conf.cpu.cpuset_cpus
            , cpuset_mems = conf.cpu.cpuset_mems
            , memswap_limit = conf.cpu.memswap_limit

            , ulimits = conf.ulimits
            , read_only = conf.read_only_rootfs
            , log_config = conf.log_config
            , security_opt = conf.security_opt

            , **conf.other_options.host_config
            )

        container_id = conf.harpoon.docker_api.create_container(image_name
            , name=container_name
            , detach=detach
            , command=command
            , volumes=volume_names
            , environment=env

            , tty = False if no_tty_option else tty
            , user = conf.user
            , ports = ports
            , stdin_open = tty

            , hostname = conf.network.hostname
            , domainname = conf.network.domainname
            , network_disabled = conf.network.disabled

            , host_config = host_config

            , **conf.other_options.create
            )

        if isinstance(container_id, dict):
            if "errorDetail" in container_id:
                raise BadImage("Failed to create container", image=name, error=container_id["errorDetail"])
            container_id = container_id["Id"]

        return container_id
782601
def docker2singularity(self, runscript="/bin/bash", force=False):
    '''
    '''

    recipe = ['Bootstrap: docker']
    recipe += [ "From: %s" %self.fromHeader ]
  
    # Sections with key value pairs
    recipe += self._create_section('files')
    recipe += self._create_section('labels')
    recipe += self._create_section('install', 'post')
    recipe += self._create_section('environ', 'environment')    

    # Take preference for user, entrypoint, command, then default
    runscript = self._create_runscript(runscript, force)
    recipe += finish_section(runscript, 'runscript')

    if self.test is not None:
        recipe += finish_section(self.test, 'test')

    # Clean up extra white spaces
    return '\n'.join(recipe).replace('\n\n','\n')
915320
public ContainerCreate create(String imageId) {
		ContainerCreate command = new ContainerCreate();
		command.image(imageId);
		action.setCommand(command);
		return command;
	}