What is an 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. there's not actually a complete OS. There's no kernel. There's no kernel modules.
Supported tags and respective
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. there's not actually a complete OS. There's no kernel. There's no kernel modules.
It's really just
the binaries that your application needs because the host provides the kernel.
That's one of the
distinct characteristics around containers that makes it different from a
virtual.
It's not booting up a full operating system.
It's really just
starting an application, and that image can be really small.
Small as one file.
Even you make it as Big as a CentOS, Ubuntu distro with apt, and apache, PHP, and more installed.
The Mighty Hub using DOCKER Hub Registry Images:
Basics of Docker Hub (hub.docker.com)
Find official and other good public images
Download images and basics of image tags
Register and login to hub.docker.com and search for the images (Eg: nginx)
There you can see the,
Supported tags and respective Dockerfile
links
Note: // All these tags in the same line are targeting same image.
Eg:
1.17.5
,mainline
,1
,1.17
,latest
1.17.5-perl
,mainline-perl
,1-perl
,1.17-perl
,perl
1.17.5-alpine
,mainline-alpine
,1-alpine
,1.17-alpine
,alpine
1.17.5-alpine-perl
,mainline-alpine-perl
,1-alpine-perl
,1.17-alpine-perl
,alpine-perl
1.16.1
,stable
,1.16
/// Stable version as on date.1.16.1-perl
,stable-perl
,1.16-perl
1.16.1-alpine
,stable-alpine
,1.16-alpine
1.16.1-alpine-perl
,stable-alpine-perl
,1.16-alpine-perl
You can pull the image by using the tags.
Eg: docker pull nginx, docker pull nginx:1.17.5.
"Explorer" tab shows you the official images,
Images and the Layers:
Image layers
Union file system
history and inspect commands
copy on write
Image layers, this is a
fundamental concept of how Docker works. It uses something called the union
file system to present a
series of file system changes as an actual file system.
The history and inspect commands and see how we can use them to
understand
PS C:\Users\MOHI> docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 775349758637 10 days ago 64.2MB
httpd latest d3017f59d5e2 11 days ago 165MB
nginx alpine b6753551581f 2 weeks ago 21.4MB
nginx latest 540a289bab6c 2 weeks ago 126MB
alpine latest 965ea09ff2eb 2 weeks ago 5.55MB
mysql latest c8ee894bd2bd 3 weeks ago 456MB
centos latest 0f3e07c0138f 5 weeks ago 220MB
centos 7 67fa590cfc1c 2 months ago 202MB
ubuntu 14.04 2c5e00d77a67 5 months ago 188MB
hello-world latest fce289e99eb9 10 months ago 1.84kB
elasticsearch 2 5e9d896dc62c 14 months ago 479MB
PS C:\Users\MOHI> docker history nginx:latest
IMAGE CREATED CREATED BY SIZE COMMENT
540a289bab6c 2 weeks ago /bin/sh -c #(nop) CMD ["nginx" "-g" "daemon… 0B
<missing> 2 weeks ago /bin/sh -c #(nop) STOPSIGNAL SIGTERM 0B
<missing> 2 weeks ago /bin/sh -c #(nop) EXPOSE 80 0B
<missing> 2 weeks ago /bin/sh -c ln -sf /dev/stdout /var/log/nginx… 22B
<missing> 2 weeks ago /bin/sh -c set -x && addgroup --system -… 57MB // Some data changes so size differs
<missing> 2 weeks ago /bin/sh -c #(nop) ENV PKG_RELEASE=1~buster 0B
<missing> 2 weeks ago /bin/sh -c #(nop) ENV NJS_VERSION=0.3.6 0B
<missing> 2 weeks ago /bin/sh -c #(nop) ENV NGINX_VERSION=1.17.5 0B
<missing> 3 weeks ago /bin/sh -c #(nop) LABEL maintainer=NGINX Do… 0B //Only Meta data changes since 0KB
<missing> 3 weeks ago /bin/sh -c #(nop) CMD ["bash"] 0B
<missing> 3 weeks ago /bin/sh -c #(nop) ADD file:74b2987cacab5a6b0… 69.2MB
What do I mean by
image layers?
It's actually
transparent completely to you when you're using Docker, but when you start
digging into certain commands,
like the history command, the inspect and commit, you start to get a sense that
an image.
Every image
starts from the very beginning with a blank layer known as scratch.
Then every set of
changes that happens after that on the file system, in the image, is another
layer.
You might have
one layer, you might have dozens of layers and some layers maybe no change in
terms of the file size.
You'll notice on
here that we actually have a change here that was simply a metadata change
about.
we're starting
with one layer. Every layer gets its own unique SHA that helps the system
identify.
What happens if I
have another image that's also using the same version of nginx?
Well, that image
can have its own changes, on top of the
same layer that I have in my cache. This is where the fundamental concept of
the cache of image layers
saves us a whole bunch of time and space. Because we don't need to download
layers we already have, and
remember it uses a unique SHA for each layer so it's guaranteed to be the exact layer it needs. It
knows how to match them between Docker Hub and our local cache. As we make
changes to our images,
they create more layers.
If we decide that
we want to have the same image be the base image for more layers, then it's
only ever storing one
copy of each layer.
In this system,
really, one of the biggest benefits is that we're never storing the same image
data more than once on our
file system.
It also means
that when we're uploading and downloading we don't need to upload and download
the same layers that we
already have on the other side.
No comments:
Post a Comment