def load_docker_commands(dockerfile_path): '''Given a dockerfile get a persistent list of docker commands''' global docker_commands docker_commands = df.get_directive_list( df.get_command_list(dockerfile_path)) global dockerfile dockerfile = dockerfile_path
def load_docker_commands(dockerfile_path): '''Given a dockerfile get a persistent list of docker commands''' if not os.path.isfile(dockerfile_path): raise IOError('{} does not exist'.format(dockerfile_path)) global docker_commands docker_commands = dockerfile.get_directive_list( dockerfile.get_command_list(dockerfile_path)) global dockerfile_global dockerfile_global = dockerfile_path
def set_imported_layers(docker_image): '''Given a Docker image object that was built from a Dockerfile, set the layers that were imported using the Dockerfile's FROM command or the ones that came before it''' dockerfile_lines = dockerfile.get_command_list(dockerfile_global) index = -1 from_line = '' for line in dockerfile_lines: if 'FROM' in line: from_line = line break for layer in docker_image.layers: instr = created_to_instruction(layer.created_by) if instr in dockerfile_lines: index = docker_image.layers.index(layer) break if index != -1: # index was set so all layers before this index has been imported for i in range(0, index): docker_image.layers[i].import_str = from_line