Friday, July 7, 2017

Store and Run docker images locally & inspect contents of docker image


==========================================

Store and Run docker images locally:


How to save image locally and use it:

// You have built an image named s3-store-build

// Now save locally
$ docker save s3-store-build > s3-store-build.tar

$ ls -ltrsh
261M -rw-rw-r--  s3-store-build.tar

// Load the image - ready to run:
$ docker load --input s3-store-build.tar

==========================================

Inspecting contents of docker image:

# get your image name from this command

docker images


# here 172.31.17.15:5000/openshift/test-apb is the image name , save it to a tar file

docker save 172.31.17.15:5000/openshift/test-apb > s3.tar


mkdir test

cd test

# extract entire image using tar
tar xf ../s3.tar


# now extract individual tar files present
for filename in `find . -name  "*.tar" `; do tar xf  $filename; done


# Now, you check whether the file you are looking for is present in the image
find . -name <some_test_file_whether_present.txt>

=================================================

No comments:

Post a Comment