'Create a new dataset in the cluster configuration.
:param unicode node_uuid: The UUID of the node on which the container
will run.
:param unicode name: A unique identifier for the container within
the Flocker cluster.
:param unicode image: The name of the Docker image to use for the
container.
:param list ports: A ``list`` of ``dict`` objects, mapping internal
to external ports for the container.
:param dict environment: A ``dict`` of key/value pairs to be supplied
to the container as environment variables. Keys and values must be
``unicode``.
:param dict restart_policy: A restart policy for the container, this
is a ``dict`` with at a minimum a "name" key, whose value must be
one of "always", "never" or "on-failure". If the "name" is given
as "on-failure", there may also be another optional key
"maximum_retry_count", containing a positive ``int`` specifying
the maximum number of times we should attempt to restart a failed
container.
:param volumes: A iterable of ``dict`` with ``"dataset_id"`` and
``"mountpoint"`` keys.
:param int cpu_shares: A positive integer specifying the relative
weighting of CPU cycles for this container (see Docker\'s run
reference for further information).
:param int memory_limit: A positive integer specifying the maximum
amount of memory in bytes available to this container.
:param list links: A ``list`` of ``dict`` objects, mapping container
links via "alias", "local_port" and "remote_port" values.
:param command_line: If not ``None``, the command line to use when
running the Docker image\'s entry point.
:param swappiness: Tune container\'s memory swappiness
(default of 0 disables swap).
:return: An ``EndpointResponse`` describing the container which has
been added to the cluster configuration.'

@app.route('/configuration/containers', methods=['POST'])
@user_documentation(u'\n                                The    container    will    be    automatically    started    once    it    is    created    on\n                                the    cluster.\n                                ', header=u'Add    a    new    container    to    the    configuration', examples=[u'create    container', u'create    container    with    duplicate    name', u'create    container    with    ports', u'create    container    with    environment', u'create    container    with    attached    volume', u'create    container    with    cpu    shares', u'create    container    with    memory    limit', u'create    container    with    links', u'create    container    with    command    line', u'create    container    with    swappiness'], section=u'container')
@structured(inputSchema={'$ref': '/v1/endpoints.json#/definitions/configuration_container'}, outputSchema={'$ref': '/v1/endpoints.json#/definitions/configuration_container'}, schema_store=SCHEMAS)
def create_container_configuration(self, node_uuid, name, image, ports=(), environment=None, restart_policy=None, cpu_shares=None, memory_limit=None, links=(), volumes=(), command_line=None, swappiness=0):

    deployment = self.persistence_service.get()
    node_uuid = UUID(hex=node_uuid)
    for node in deployment.nodes.itervalues():
        if (name in node.applications):
            raise CONTAINER_NAME_COLLISION
    attached_volume = None
    if volumes:
        attached_volume = self._get_attached_volume(node_uuid, volumes[0])
    node = deployment.get_node(node_uuid)
    for port in ports:
        for current_node in deployment.nodes.itervalues():
            for application in current_node.applications.values():
                for application_port in application.ports:
                    if (application_port.external_port == port['external']):
                        raise CONTAINER_PORT_COLLISION
    link_aliases = set()
    link_local_ports = set()
    application_links = set()
    for link in links:
        if (link['alias'] in link_aliases):
            raise LINK_ALIAS_COLLISION
        if (link['local_port'] in link_local_ports):
            raise LINK_PORT_COLLISION
        link_aliases.add(link['alias'])
        link_local_ports.add(link['local_port'])
        application_links.add(Link(alias=link['alias'], local_port=link['local_port'], remote_port=link['remote_port']))
    application_ports = []
    for port in ports:
        application_ports.append(Port(internal_port=port['internal'], external_port=port['external']))
    if (environment is not None):
        environment = frozenset(environment.items())
    if (restart_policy is None):
        restart_policy = dict(name=u'never')
    policy_name = restart_policy.pop('name')
    policy_factory = FLOCKER_RESTART_POLICY_NAME_TO_POLICY[policy_name]
    policy = policy_factory(**restart_policy)
    application = Application(name=name, image=DockerImage.from_string(image), ports=frozenset(application_ports), environment=environment, volume=attached_volume, restart_policy=policy, cpu_shares=cpu_shares, memory_limit=memory_limit, links=application_links, command_line=command_line, swappiness=swappiness)
    new_node_config = node.transform(['applications'], (lambda s: s.set(application.name, application)))
    new_deployment = deployment.update_node(new_node_config)
    saving = self.persistence_service.save(new_deployment)
    def saved(_):
        result = container_configuration_response(application, node_uuid)
        return EndpointResponse(CREATED, result)
    saving.addCallback(saved)
    return saving
