def create_container(image, command=None, hostname=None, user=None, detach=True, stdin_open=False, tty=False, mem_limit=None, ports=None, environment=None, dns=None, volumes=None, volumes_from=None, name=None, cpu_shares=None, cpuset=None, binds=None):
 log.trace(('modules.dockerio.create_container() called for image ' + image))
 status = base_status.copy()
 client = _get_client()
 if isinstance(volumes, list):
  for volume in volumes:
   if (':' in volume):
    volspec = volume.split(':')
    source = volspec[0]
    target = volspec[1]
    ro = False
    try:
     if (len(volspec) > 2):
      ro = (volspec[2] == 'ro')
    except IndexError:
     pass
    binds[source] = {'bind': target, 'ro': ro}
    volumes.remove(volume)
 try:
  if (salt.utils.version_cmp(client.version()['ApiVersion'], '1.18') == 1):
   container_info = client.create_container(image=image, command=command, hostname=hostname, user=user, detach=detach, stdin_open=stdin_open, tty=tty, ports=ports, environment=environment, dns=dns, volumes=volumes, volumes_from=volumes_from, name=name, cpu_shares=cpu_shares, cpuset=cpuset, host_config=docker.utils.create_host_config(binds=binds, mem_limit=mem_limit))
  else:
   container_info = client.create_container(image=image, command=command, hostname=hostname, user=user, detach=detach, stdin_open=stdin_open, tty=tty, mem_limit=mem_limit, ports=ports, environment=environment, dns=dns, volumes=volumes, volumes_from=volumes_from, name=name, cpu_shares=cpu_shares, cpuset=cpuset, host_config=docker.utils.create_host_config(binds=binds))
  log.trace(('docker.client.create_container returned: ' + str(container_info)))
  container = container_info['Id']
  callback = _valid
  comment = 'Container created'
  out = {'info': _get_container_infos(container), 'out': container_info}
  __salt__['mine.send']('dockerng.ps', verbose=True, all=True, host=True)
  return callback(status, id_=container, comment=comment, out=out)
 except Exception as e:
  _invalid(status, id_=image, out=traceback.format_exc())
  raise e
 __salt__['mine.send']('dockerng.ps', verbose=True, all=True, host=True)
 return status

def create_container ( image , command = None , hostname = None , user = None , detach = True , stdin_open = False , tty = False , mem_limit = None , ports = None , environment = None , dns = None , volumes = None , volumes_from = None , name = None , cpu_shares = None , cpuset = None , binds = None ) : log . trace ( ( 'modules.dockerio.create_container() called for image ' + image ) ) status = base_status . copy ( ) client = _get_client ( ) if isinstance ( volumes , list ) : for volume in volumes : if ( ':' in volume ) : volspec = volume . split ( ':' ) source = volspec [ 0 ] target = volspec [ 1 ] ro = False try : if ( len ( volspec ) > 2 ) : ro = ( volspec [ 2 ] == 'ro' ) except IndexError : pass binds [ source ] = { 'bind' : target , 'ro' : ro } volumes . remove ( volume ) try : if ( salt . utils . version_cmp ( client . version ( ) [ 'ApiVersion' ] , '1.18' ) == 1 ) : container_info = client . create_container ( image = image , command = command , hostname = hostname , user = user , detach = detach , stdin_open = stdin_open , tty = tty , ports = ports , environment = environment , dns = dns , volumes = volumes , volumes_from = volumes_from , name = name , cpu_shares = cpu_shares , cpuset = cpuset , host_config = docker . utils . create_host_config ( binds = binds , mem_limit = mem_limit ) ) else : container_info = client . create_container ( image = image , command = command , hostname = hostname , user = user , detach = detach , stdin_open = stdin_open , tty = tty , mem_limit = mem_limit , ports = ports , environment = environment , dns = dns , volumes = volumes , volumes_from = volumes_from , name = name , cpu_shares = cpu_shares , cpuset = cpuset , host_config = docker . utils . create_host_config ( binds = binds ) ) log . trace ( ( 'docker.client.create_container returned: ' + str ( container_info ) ) ) container = container_info [ 'Id' ] callback = _valid comment = 'Container created' out = { 'info' : _get_container_infos ( container ) , 'out' : container_info } __salt__ [ 'mine.send' ] ( 'dockerng.ps' , verbose = True , all = True , host = True ) return callback ( status , id_ = container , comment = comment , out = out ) except Exception as e : _invalid ( status , id_ = image , out = traceback . format_exc ( ) ) raise e __salt__ [ 'mine.send' ] ( 'dockerng.ps' , verbose = True , all = True , host = True ) return status
create a container .