Docker Classroom Series – 27/Sep/2019

Docker Image Layers

Refer here for image creation & understanding layers

Experiments

  • Lets pull a docker image docker pull alpine
  • Lets examine Layers. Execute command docker image inspect alpine
  • Make a note of Rootfs
"RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:03901b4a2ea88eeaad62dbe59b072b28b6efa00491962b8741081c5df50c65e0"
            ]
        }
  • Lets do the same with different image docker pull tomcat:8 && docker image inspect tomcat:8. Make note of Rootfs
"RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:55e6b89812f369277290d098c1e44c9e85a5ab0286c649f37e66e11074f8ebd1",
                "sha256:26b1991f37bd5b798e1523f65d7f6aa6961b75515f465cf44123fa0ad3b8961b",
                "sha256:8bacec4e34468110538ebf108ca8ec0d880a37018a55be91b9670b8e900c593a",
                "sha256:2e669e0134f53839293f077f21dd124634f92aa5f7e3fd013c530779dd41d1c5",
                "sha256:5a30999619d793135da20f07cef97d34e741dbae20364ad87803e7a26906b365",
                "sha256:1690af51cb08c01e45b1ad3ea2d6e6ad68e6eaf88bd01b8725d21cb782849dac",
                "sha256:57e6a3d20ce900546bb12f793c7c4057f87b7b509488f42c68d1772380e5e6e0",
                "sha256:5161954b2663c24f662d3b8f7dd404821bf8ba77fdd405a327be76061490bbe1",
                "sha256:bee27ee72bbdce8cf0d487ea3ccd8b6b208ebc1d1ae6bcfd92da9e18381a460f",
                "sha256:3d7c5e9cb860fcb040f7df0331c460dae60e3fe03ce075837ccc3f1b1176aede"
            ]
        }
  • Lets do the same for tomcat:9
"RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:55e6b89812f369277290d098c1e44c9e85a5ab0286c649f37e66e11074f8ebd1",
                "sha256:26b1991f37bd5b798e1523f65d7f6aa6961b75515f465cf44123fa0ad3b8961b",
                "sha256:8bacec4e34468110538ebf108ca8ec0d880a37018a55be91b9670b8e900c593a",
                "sha256:2e669e0134f53839293f077f21dd124634f92aa5f7e3fd013c530779dd41d1c5",
                "sha256:5a30999619d793135da20f07cef97d34e741dbae20364ad87803e7a26906b365",
                "sha256:4e8bbb91df0400bfa8e435e3aceddeb4fa69c633570b8d93a863d08ed4e41721",
                "sha256:57f260974b764bbcf9ddea8ad1e14a91ecfa1be54d03f5f61d699bd25d815598",
                "sha256:80dc36c9ba8c710a238be61b68403b854940248bd2d8b31e39e6a2de63a0e76e",
                "sha256:13cb70b6919782948114761573401a60ea70f68af9fa36f371005ff88f2b32c1",
                "sha256:720d011cc35aaa8dc148522e49bbb4c4567e23840f1a2ab50a1e3103b0e0a818"
            ]
        }
  • Layer Creation are done during image creation. Simple Logic is in Dockerfile instructions (RUN, ADD, COPY) lead to image layer creation

  • Lets try this

FROM alpine
RUN echo "hello to new layer" >> test.txt 

  • Create a image by execute docker image build -t testlayer .
  • Now inspect this images docker image inspect testlayer and make note of rootfs
"RootFS": {
            "Type": "layers",
            "Layers": [
                "sha256:03901b4a2ea88eeaad62dbe59b072b28b6efa00491962b8741081c5df50c65e0",
                "sha256:f5ca6f6050faa8316489da066e4b7d760af71635568be558254d929d5a04f289"
            ]
        }
  • Union File System:

    • Docker uses union file system to make things work with image layers
  • Imapact of Layers on Image Preview

  • Impact of Layers on Container Preview

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube