DevOps Blog - Nicolas Paris

Keep Track of Base Docker Image from multiple projects

DevOps

This is a very quick trick to keep track of your base image when you have multiple projects insinde a directory with grep.

If you want to quickly list all of your FROM line of Dockerfile with a grep command, try the following one.

grep -R --exclude-dir=node_modules --exclude-dir=vendor "FROM" */Dockerfile | grep php

Here is an example where only the php version is an interest for me.

$ grep -R --exclude-dir=node_modules --exclude-dir=vendor "FROM" */Dockerfile | grep php
project-a/Dockerfile:FROM php:8.1-fpm-alpine
project-b/Dockerfile:FROM php:8.1-alpine
project-c/Dockerfile:FROM php:7.3-alpine
project-d/Dockerfile:FROM php:7.2-apache
project-e/Dockerfile:FROM php:8.1-fpm-alpine

Like this, you can easely spot outdate php and image not based on Alpine.

Told you, it was a quick trick.