code: async def create(
          self,
          task_template: Mapping[str, Any],
          *,
          name: str = None,
          labels: List = None,
          mode: Mapping = None,
          update_config: Mapping = None,
          rollback_config: Mapping = None,
          networks: List = None,
          endpoint_spec: Mapping = None,
          auth: Optional[Union[MutableMapping, str, bytes]] = None,
          registry: str = None
      ) -> Mapping[str, Any]:
          
  
          if "Image" not in task_template["ContainerSpec"]:
              raise KeyError("Missing mandatory Image key in ContainerSpec")
  
          if auth and registry is None:
              raise KeyError(
                  "When auth is specified you need to specifiy also the registry"
              )
  
          # from {"key":"value"} to ["key=value"]
          if "Env" in task_template["ContainerSpec"]:
              task_template["ContainerSpec"]["Env"] = [
                  format_env(k, v)
                  for k, v in task_template["ContainerSpec"]["Env"].items()
              ]
  
          headers = None
          if auth:
              headers = {"X-Registry-Auth": compose_auth_header(auth, registry)}
  
          config = {
              "TaskTemplate": task_template,
              "Name": name,
              "Labels": labels,
              "Mode": mode,
              "UpdateConfig": update_config,
              "RollbackConfig": rollback_config,
              "Networks": clean_networks(networks),
              "EndpointSpec": endpoint_spec,
          }
  
          data = json.dumps(clean_map(config))
  
          response = await self.docker._query_json(
              "services/create", method="POST", data=data, headers=headers
          )
          return response
docs: Create a service
  
          Args:
              task_template: user modifiable task configuration
              name: name of the service
              labels: user-defined key/value metadata
              mode: scheduling mode for the service
              update_config: update strategy of the service
              rollback_config: rollback strategy of the service
              networks: array of network names/IDs to attach the service to
              endpoint_spec: ports to expose
              auth: authentication information, can be a string, dict or bytes
              registry: used when auth is specified, it provides domain/IP of
                  the registry without a protocol
  
          Returns:
              a dict with info of the created service