Return the command as a single string for the docker file
429101
def as_string(self):
        """"""
        if type(self.instruction) is str:
            return self.instruction

        if self.action == "FROM" and not isinstance(self.command, six.string_types):
            extra = "" if self.extra is NotSpecified else " {0}".format(self.extra)
            return "{0} {1}{2}".format(self.action, self.command.from_name, extra)
        else:
            return "{0} {1}".format(self.action, self.command)
839273
def get_command(self, pure=False):
        
        command = self.get_full_command()
        if command:
            command = command[0]
            if pure:
                command, _, _ = command[1:].partition('@')
            return command
742024
def output_command(info, image_info, pretty=False):
    ''''''

    sep = pretty and ' \\\n    ' or ' '

    short_options = ''
    options = []

    container = info['Name'][1:]
    conf = info['Config']
    hconf = info['HostConfig']

    options.append("--name={name}".format(name=container))

    if not conf['AttachStdout']:
        short_options += 'd'

    if conf['OpenStdin']:
        short_options += 'i'

    if conf['Tty']:
        short_options += 't'

    if len(short_options) > 0:
        options.append('-' + short_options)

    options.append("-h {hostname}".format(hostname=conf['Hostname']))

    # Volumes
    if 'Binds' in hconf and isinstance(hconf['Binds'], list):
        for volume in hconf['Binds']:
            options.append("-v {volume}".format(volume=volume))

    # PortBindings
    if 'PortBindings' in hconf and isinstance(hconf['PortBindings'], dict):
        for port, hosts in hconf['PortBindings'].items():
            for host in hosts:
                portbinding = ''
                if 'HostIp' in host and host['HostIp']:
                    portbinding += host['HostIp'] + ':'
                if 'HostPort' in host and host['HostPort']:
                    portbinding += host['HostPort'] + ':'
                portbinding += port
                options.append("-p {portbinding}".format(portbinding=portbinding))

    # Devices
    if 'Devices' in hconf and isinstance(hconf['Devices'], list):
        for device in hconf['Devices']:
            options.append("--device={device}".format(device=device))

    # RestartPolicy
    if 'RestartPolicy' in hconf and hconf['RestartPolicy']['Name']:
        policy = hconf['RestartPolicy']['Name']
        if hconf['RestartPolicy']['MaximumRetryCount'] > 0:
            policy += ':' + str(hconf['RestartPolicy']['MaximumRetryCount'])
        options.append("--restart={policy}".format(policy=policy))

    # Privileged
    if hconf['Privileged']:
        options.append('--privileged')

    # DNS
    if 'Dns' in hconf and isinstance(hconf['Dns'], list):
        for dns in hconf['Dns']:
            options.append("-dns={dns}".format(dns=dns))

    # ExposedPorts
    if 'ExposedPorts' in conf and isinstance(conf['ExposedPorts'], dict):
        for port, _ in conf['ExposedPorts'].items():
            if ('ExposedPorts' not in image_info['Config'] or
                    port not in image_info['Config']['ExposedPorts']):
                options.append("--expose={port}".format(port=port))

    # Env
    if isinstance(conf['Env'], list):
        for env in conf['Env']:
            if env not in image_info['Config']['Env']:
                options.append("-e {env}".format(env=pipes.quote(env)))

    # EntryPoint
    if conf['Entrypoint'] != image_info['Config']['Entrypoint']:
        entry = []
        if isinstance(conf['Entrypoint'], list):
            for entry_item in conf['Entrypoint']:
                entry.append(pipes.quote(entry_item))
        elif isinstance(conf['Entrypoint'], str):
            entry.append(pipes.quote(conf['Entrypoint']))
        if len(entry) > 0:
            options.append("--entrypoint={entry}".format(entry=pipes.quote(' '.join(entry))))

    # WorkingDir
    if image_info['Config']['WorkingDir'] != conf['WorkingDir']:
        options.append("-w {dir}".format(dir=pipes.quote(conf['WorkingDir'])))

    # User
    if conf['User'] and image_info['Config']['User'] != conf['User']:
        options.append("-u {user}".format(user=pipes.quote(conf['User'])))

    # Cmd
    cmd = []
    if conf['Cmd'] != image_info['Config']['Cmd']:
        if isinstance(conf['Cmd'], list):
            for cmd_item in conf['Cmd']:
                cmd.append(pipes.quote(cmd_item))
        elif isinstance(conf['Cmd'], str):
            cmd.append(pipes.quote(conf['Cmd']))

    print('# docker-run command for {container}'.format(container=container))
    cmd_str = 'docker run{sep}{options}{sep}{image}'.format(
        options=sep.join(options), sep=sep, image=conf['Image'])

    if len(cmd) > 0:
        cmd_str += ' ' + ' '.join(cmd)

    print(cmd_str)
    print()
1109470
def get_create_command(self):
        """"""
        command = ['git', 'clone' if self.remote else 'init']
        if self.bare:
            command.append('--bare')
        if self.remote:
            command.append(self.remote)
        command.append(self.local)
        return command
946094
def ssh_cmd(self, name, ssh_command):
        
        if not self.container_exists(name=name):
            exit("Unknown container {0}".format(name))

        if not self.container_running(name=name):
            exit("Container {0} is not running".format(name))

        ip = self.get_container_ip(name)
        if not ip:
            exit("Failed to get network address for "
                 "container {0}".format(name))
        if ssh_command:
            ssh.do_cmd('root', ip, 'password', " ".join(ssh_command))
        else:
            ssh.launch_shell('root', ip, 'password')
687636
def get_output(command):
    """"""
    p = Popen(command, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
    p.stdin.close()
    p.stderr.close()
    line=p.stdout.readline().strip()
    p.wait()
    if type(line).__name__ == "bytes":
        line = str(line, encoding="utf-8")
    return line, p.returncode
570061
def output_file(self, _container):
        """"""
        p = local.path(_container)
        if p.exists():
            if not ui.ask("Path '{0}' already exists."
                          " Overwrite?".format(p)):
                sys.exit(0)
        CFG["container"]["output"] = str(p)
144264
def lines_iter(self):
        '''
        
        '''
        # Convert unicode chars to string
        byte_to_string = lambda x: x.strip().decode(u'utf-8') if isinstance(x, bytes) else x.strip()

        # Read the entire contents of the Dockerfile, decoding each line, and return the result as an array
        with open(self.docker_file_path, u'r') as f:
            for line in f:
                yield byte_to_string(line)
221161
def _build_command(self):
        

        command = [self._path]
        command.extend(["-H", "{}:{}".format(self._host, self._port)])
        if log.getEffectiveLevel() == logging.DEBUG:
            command.extend(["-d", "2"])
        return command
235088
def __get_docker_file_path(path):
    '''
    
    '''
    if os.path.isfile(path):
        return path
    for dc_filename in DEFAULT_DC_FILENAMES:
        file_path = os.path.join(path, dc_filename)
        if os.path.isfile(file_path):
            return file_path
326756
def docker_inspect(image):
    '''
    '''
    args = ['docker', 'inspect', '--type', 'image', image]
    p = Popen(args, stdout = subprocess.PIPE, stderr = subprocess.PIPE)

    stdout, stderr = p.communicate()
    stdout = stdout.decode('utf-8')
    stderr = stderr.decode('utf-8')

    if not p.returncode == 0:
        if 'no such image' in stderr.lower():
            raise NoSuchImageError(image)
        raise DockerError('Failed to inspect image: {}'.format(stderr.strip()))

    return json.loads(stdout)[0]
1018242
def capture_shell(command):
    
    proc = subprocess.Popen(command,
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE,
                            shell=True)

    return proc.communicate()
1153613
def ossystem(cmd):
  """"""
  p = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE,
                       stderr=subprocess.STDOUT)
  (stdout, stderr) = p.communicate()
  return stdout.decode('ascii')
79247
function() {

    // Get docker bin path
    var dockerPath = getBinPath();
    var dockerBin = path.join(dockerPath, 'docker');

    // Return exec based on path
    switch (process.platform) {
      case 'darwin': return dockerBin;
      case 'linux': return dockerBin;
      case 'win32': return dockerBin + '.exe';
    }

  }
1363164
def get_full_command(self):
        
        if self.is_command():
            command, _, args = self.text.partition(' ')
            return command, args
440511
def build_docker_build_command(configuration):
    
    parts = configuration.pop('docker', 'docker').split()
    parts.append('build')

    build = configuration.pop('build')

    build['path'] = os.path.join(configuration['workspace'], build['path'])
    build['file'] = os.path.join(build['path'], build['file'])

    parts.extend(build_parameter_parts(
        build, 'tag', 'file', 'no-cache', 'quiet', 'cpu-shares', 'memory'))

    parts.extend(build_dict_parameter_parts(build, 'build-arg'))
    parts.append(build.pop('path'))

    return parts
181511
def get(path):
    '''
    
    '''
    file_path = __get_docker_file_path(path)
    if file_path is None:
        return __standardize_result(False,
                                    'Path {} is not present'.format(path),
                                    None, None)
    salt_result = __read_docker_compose_file(file_path)
    if not salt_result['status']:
        return salt_result
    project = __load_project(path)
    if isinstance(project, dict):
        salt_result['return']['valid'] = False
    else:
        salt_result['return']['valid'] = True
    return salt_result