class_docstr: Handle the lifecycle and configuration of a local container execution.
  
  This class is responsible for creating the directories and configuration
  files that the docker containers will use for either training or serving.
class_docstr_tok: ["Handle","the","lifecycle","and","configuration","of","a","local","container","execution",".","This","class","is","responsible","for","creating","the","directories","and","configuration","files","that","the","docker","containers","will","use","for","either","training","or","serving","."]
docstr: Creates the docker host configuration.
  
  Args:
      host (str): The host address
      environment (List[str]): List of environment variables
      optml_subdirs (Set[str]): Set of subdirs
      command (str): Either 'train' or 'serve'
      volumes (list): List of volumes that will be mapped to the containers
docstr_tok: ["Creates","the","docker","host","configuration",".","Args",":","host","(","str",")",":","The","host","address","environment","(","List","[","str","]",")",":","List","of","environment","variables","optml_subdirs","(","Set","[","str","]",")",":","Set","of","subdirs","command","(","str",")",":","Either","'train","'","or","'serve'","volumes","(","list",")",":","List","of","volumes","that","will","be","mapped","to","the","containers"]
code: def _create_docker_host(
      self,
      host: str,
      environment: List[str],
      optml_subdirs: set[str],
      command: str,
      volumes: List,
  ) -> Dict:
      """Creates the docker host configuration.
  
      Args:
          host (str): The host address
          environment (List[str]): List of environment variables
          optml_subdirs (Set[str]): Set of subdirs
          command (str): Either 'train' or 'serve'
          volumes (list): List of volumes that will be mapped to the containers
      """
      optml_volumes = self._build_optml_volumes(host, optml_subdirs)
      optml_volumes.extend(volumes)
  
      container_name_prefix = "".join(
          random.choice(string.ascii_lowercase + string.digits)
          for _ in range(10)
      )
      container_default_config = (
          sagemaker.utils.get_config_value(
              f"{LOCAL}.{CONTAINER_CONFIG}",
              self.sagemaker_session.config,
          )
          or {}
      )
  
      host_config = {
          **container_default_config,
          "image": self.image,
          "container_name": f"{container_name_prefix}-{host}",
          "stdin_open": True,
          "tty": True,
          "volumes": [v.map for v in optml_volumes],
          "environment": environment,
      }
  
      is_train_with_entrypoint = False
      if command == "train" and self.container_entrypoint:
          # Remote function or Pipeline function step is translated into a training job
          # with container_entrypoint configured
          is_train_with_entrypoint = True
  
      if command != "process" and not is_train_with_entrypoint:
          host_config["command"] = command
      else:
          if self.container_entrypoint:
              host_config["entrypoint"] = self.container_entrypoint
          if self.container_arguments:
              host_config["entrypoint"] = (
                  host_config["entrypoint"] + self.container_arguments
              )
  
      if self.is_studio:
          host_config["network_mode"] = "sagemaker"
      else:
          host_config["networks"] = {
              "sagemaker-local": {"aliases": [host]}
          }
  
      # for GPU support pass in nvidia as the runtime, this is equivalent
      # to setting --runtime=nvidia in the docker commandline.
      if self.instance_type == "local_gpu":
          host_config["deploy"] = {
              "resources": {
                  "reservations": {
                      "devices": [{"capabilities": ["gpu"]}]
                  }
              }
          }
  
      if not self.is_studio and command == "serve":
          serving_port = (
              sagemaker.utils.get_config_value(
                  "local.serving_port", self.sagemaker_session.config
              )
              or 8080
          )
          host_config.update({"ports": ["%s:8080" % serving_port]})
  
      return host_config
  
imports: from __future__ import absolute_import, annotations
  import base64
  import copy
  import errno
  import json
  import logging
  import os
  import platform
  import random
  import re
  import shlex
  import shutil
  import string
  import subprocess
  import sys
  import tarfile
  import tempfile
  from distutils.spawn import find_executable
  from threading import Thread
  from typing import Dict, List
  from six.moves.urllib.parse import urlparse
  import sagemaker
  from sagemaker.config.config_schema import CONTAINER_CONFIG, LOCAL
  import sagemaker.local.data
  import sagemaker.local.utils
  import sagemaker.utils
label_desc: Use image node_id 17 for calling the _SageMakerContainer obj's underlying member method code with example usage: obj._create_docker_host(host, environment, optml_subdirs, command, volumes) and returns: host_config