Docker save using a pattern

Gloria Palma González
1 min readApr 22, 2019

--

@ZatoryPrivate

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!

--

--

Gloria Palma González
Gloria Palma González

Written by Gloria Palma González

My life is a paradigm: I can do anything. IT engineer, melomaniac, in love: #Infrastructure #OpenSource #CommunityLeadershipTeams #SoftwareEngineering

No responses yet