Skip to content

Commit

Permalink
Retrying docker export with local id
Browse files Browse the repository at this point in the history
Signed-off-by: Prabhu Subramanian <prabhu@appthreat.com>
  • Loading branch information
prabhu committed Oct 20, 2023
1 parent 59c8252 commit 4a1d4ef
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions docker.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ export const parseImageName = (fullImageName) => {
fullImageName = fullImageName.replace(":" + nameObj.tag, "");
}
}
if (fullImageName && fullImageName.startsWith("library/")) {
fullImageName = fullImageName.replace("library/", "");
}
// The left over string is the repo name
nameObj.repo = fullImageName;
return nameObj;
Expand All @@ -336,9 +339,6 @@ export const getImage = async (fullImageName) => {
let pullData = undefined;
const { repo, tag, digest } = parseImageName(fullImageName);
let repoWithTag = `${repo}:${tag !== "" ? tag : ":latest"}`;
if (repoWithTag.startsWith("library/")) {
repoWithTag = repoWithTag.replace("library/", "");
}
// Fetch only the latest tag if none is specified
if (tag === "" && digest === "") {
fullImageName = fullImageName + ":latest";
Expand Down Expand Up @@ -741,7 +741,26 @@ export const exportImage = async (fullImageName) => {
})
);
} catch (err) {
console.error(err);
if (localData && localData.Id) {
console.log(`Retrying with ${localData.Id}`);
try {
await stream.pipeline(
client.stream(`images/${localData.Id}/get`),
x({
sync: true,
preserveOwner: false,
noMtime: true,
noChmod: true,
strict: true,
C: tempDir,
portable: true,
onwarn: () => {}
})
);
} catch (err) {
console.log(err);
}
}
}
}
// Continue with extracting the layers
Expand Down

0 comments on commit 4a1d4ef

Please sign in to comment.