Docker save using a pattern
1 min readApr 22, 2019
Sometimes you need to save images but with a specific pattern, this is a simple way to do it:
$ docker save -o my-tar.tar $(docker images | grep my-pattern | tr -s ' ' | cut -d ' ' -f 1)
Example, I need only the Redhat images:
docker save -o install.tar $(docker images | grep registry.access.redhat.com | tr -s ' ' | cut -d ' ' -f 1)
My advice is first test using echo to check if the result is the expected:
$ echo $(docker images | grep my-pattern | tr -s ' ' | cut -d ' ' -f 1)
Chao!