fix: local images for reverting

This commit is contained in:
Andras Bacsai
2023-01-10 12:24:22 +01:00
parent ee55e039b2
commit e83de8b938

View File

@@ -845,15 +845,16 @@ export async function getDockerImages(request) {
try { try {
const { stdout } = await executeCommand({ const { stdout } = await executeCommand({
dockerId: application.destinationDocker.id, dockerId: application.destinationDocker.id,
command: `docker images --format '{{.Repository}}#{{.Tag}}#{{.CreatedAt}}' | grep -i ${id} | grep -v cache`, command: `docker images --format '{{.Repository}}#{{.Tag}}#{{.CreatedAt}}'`
shell: true
}); });
const { stdout: runningImage } = await executeCommand({ const { stdout: runningImage } = await executeCommand({
dockerId: application.destinationDocker.id, dockerId: application.destinationDocker.id,
command: `docker ps -a --filter 'label=com.docker.compose.service=${id}' --format {{.Image}}` command: `docker ps -a --filter 'label=com.docker.compose.service=${id}' --format {{.Image}}`
}); });
const images = stdout.trim().split('\n'); const images = stdout
.trim()
.split('\n')
.filter((image) => image.includes(id) && !image.includes('-cache'));
for (const image of images) { for (const image of images) {
const [repository, tag, createdAt] = image.split('#'); const [repository, tag, createdAt] = image.split('#');
if (tag.includes('-')) { if (tag.includes('-')) {
@@ -874,6 +875,7 @@ export async function getDockerImages(request) {
runningImage runningImage
}; };
} catch (error) { } catch (error) {
console.log(error);
return { return {
imagesAvailables imagesAvailables
}; };