Create a new container

    image
        image to create the container from
    command
        command to execute while starting
    hostname
        hostname of the container
    user
        user to run docker as
    detach
        daemon mode
    entrypoint
        entrypoint to the container
    stdin_open
        let stdin open
    tty
        attach ttys
    mem_limit:
        memory size limit
    cpu_shares:
        cpu shares authorized
    ports
        ports redirections ({'222': {}})
    environment
        environment variable mapping ({'foo':'BAR'})
    dns
        list of DNS servers
    volumes
        list of volumes mapping::

            (['/mountpoint/in/container:/guest/foo',
              '/same/path/mounted/point'])
    volumes_from
        container to get volumes definition from
    name
        name given to container

    Returns: created container / None

def create_container(config,
                     image,
                     command=None,
                     hostname=None,
                     user=None,
                     detach=True,
                     entrypoint=None,
                     stdin_open=False,
                     tty=False,
                     mem_limit=0,
                     cpu_shares=None,
                     ports=None,
                     environment=None,
                     dns=None,
                     volumes=None,
                     volumes_from=None,
                     name=None,
                     *args, **kwargs):
    '''
    Create a new container

    image
        image to create the container from
    command
        command to execute while starting
    hostname
        hostname of the container
    user
        user to run docker as
    detach
        daemon mode
    entrypoint
        entrypoint to the container
    stdin_open
        let stdin open
    tty
        attach ttys
    mem_limit:
        memory size limit
    cpu_shares:
        cpu shares authorized
    ports
        ports redirections ({'222': {}})
    environment
        environment variable mapping ({'foo':'BAR'})
    dns
        list of DNS servers
    volumes
        list of volumes mapping::

            (['/mountpoint/in/container:/guest/foo',
              '/same/path/mounted/point'])
    volumes_from
        container to get volumes definition from
    name
        name given to container

    Returns: created container / None
    '''

    err = "Unknown"
    client = _get_client(config)
    try:
        img_infos = _get_image_infos(config, image)
        mountpoints = {}
        binds = {}
        # create empty mountpoints for them to be
        # editable
        # either we have a list of guest or host:guest
        if isinstance(volumes, list):
            for mountpoint in volumes:
                mounted = mountpoint
                if ':' in mountpoint:
                    parts = mountpoint.split(':')
                    mountpoint = parts[1]
                    mounted = parts[0]
                mountpoints[mountpoint] = {}
                binds[mounted] = mountpoint
        info = _set_id(client.create_container(
            image=image,
            command=command,
            hostname=hostname,
            user=user,
            entrypoint=entrypoint,
            detach=detach,
            stdin_open=stdin_open,
            tty=tty,
            mem_limit=mem_limit,
            ports=ports,
            environment=environment,
            dns=dns,
            volumes=mountpoints,
            volumes_from=volumes_from,
            name=name,
            cpu_shares=cpu_shares
        ))
        print "Container '%s' created."%info['Id']
        return info
    except Exception as e:
        err = e
    utils.error("Unable to create your container: %s"%err)
    return None