Thursday, September 13, 2018

Images and layers

What is an image?

 Is made up of filesystems layered over each other.
A docker image = OS user space - Kernel
Kernel is Heart of OS, which will do all processing.

Let's take a Docker base image.

Base -> Boot fole system -> boot fs -> uses a union file system and root filesystem stays in read-only mode.

union file system (unionfs) allows files and directories of separate file systems., to be transparently overlaid, forming a single coherent file system.
Basically a tar file.
When a container is launched from an image, Docker mounts a read-write filesystem on top of any layers below.





More detailed:

Image:
--------
  • App binaries and dependencies.
  • Metadata about the image data and how to run the image.
  • Official definition: An image is an ordered collection of root filesystem changes and the corresponding execution parameters for use within a container runtime.
  • Not a complete OS.No kernel, kernel modules (e.g. drivers)
  • Kernel is used from Host and only app binaries are availabe in it.
  • Small as one file (your app binary) like a golang static binary
  • Big as a Ubuntu distro with apt, and Apache, PHP, and more installed.

Repo for docker images. : hub.docker.com
They have many public and private repos once you log in.
ex: many nginx images are there and one image is mentioned in the description as official..it doesn't have a forward slash in it.Other images contains accounts names and forward slash.
official images are created by docker official team

the explore button on top of web pages shows list of many official repos.

list of images on the local machine:
docker image ls

to download an image
docker pull nginx
--it will download the image with default tag: latest
--if already downloaded latest, it will show as up to date.
docker pull nginx:1.11.9
--it downloads version 1.11.9
--in the description of repo on webiste, it shows supported tags.
tag: 1.11.9-alpine means it comes from base image called alpine.
the latest or default comes from jessie(debian)

beside every  repo image, there is stars and pulls mentioned to rate when we are using a non-official image.
and the source image section contains link to github for that repo.

docker image history nginx:latest (old way: docker history)
docker history mysql
shows layers of changes made in image
those may be just file changes or application changes, whatever we want and store that as a layer. Like opening a port, copying a file, adding an env. variable.
we have unique sha for each layer, and no need to download the image layer for a different copy to create.
If the base image for different images are same, then both will point to same copy, won't download again.
image layers are stored as docker files.









docker image inspect nginx  (oldway: docker inspect)
returns json metadata about the image..shows also how this image expected to run.




       

No comments:

Post a Comment