This question is a little vague. Sorry I do not have more details. I did an exam a few days ago that involved containers. One question was about optimizing an existing docker file, creating the image and pushing it to docker hub. The docker file included EXPOSE, CMD, LABEL, FROM RUN, ADD instructions.
One of the characteristics of the image was that one should be able to use it as base/parent image for creating other images.
I can't believe this mention was added for no reason. Yet I am not able to understand why this characteristic had to be listed. Is there something specific that one needs to add in docker files for base images? Or are base images stored differently in the registry?
What makes a base docker image different than a normal runnable image?
There is nothing special that you need to do for an image to be reusable. All images can be used in the FROM clause and thus used as base images. The OS needs to match the commands in the file, of course. Also images are made of layers and layers are usually reused between images.
If I would have to look hard for a reason why that was specified as a requirement, I would say that they wanted you to pay attention to:
the size of the final image (make it as small as possible)
documentation (make it easy for others to understand what your image already does)
Related
I'm looking for a visual tool that would take a Docker image and be able to show (in some kind of a chart) what makes the image e.g. 1,2GB large.
In addition to what disk tools would do, it would also tell me which Docker overlay brought that file in.
Is there such a tool or shall I dream on?
Dive does it.
Mentioned here.
What is the advantage over using a heavy base image like Ubuntu 14.04 than a lightweight one like Alpine? Is using a sophisticated base image more secure than a light weight one?
The size. Heavy image as you put it, will be big and not as fast to pull as a lightweight image. The base alpine image is around 5MB (that is the same size as the Windows Start button).
For example alpine-based image with mysql is 16MB while an equivalent image based on ubuntu is 232MB. Thats more than 14 times bigger than it should be. I can't think of a reason you would need a mysql image to be based on ubuntu.
So, the advantages are:
the speed: lightweight image is downloaded, installed and run much faster
security: improved security as the image has a smaller footprint
migration: faster migration between hosts
disk space: you will use much less disk space
Docker has changed it's backend and now the "docker history" command no longer shows layer IDs of all layers in an image. More details here: https://github.com/docker/docker/issues/20131
Although I understand why it's showing "missing", I still havent found a new way to extract the information I'm looking for. Does anyone know how I can find all the layers in an image? I'd like to be able to cross-reference layers over different images so that I know when a certain layer is used by more than once service, which is why I used the ID shown in the history command up until recentely.
Any help is appreciated, thank you.
When we do,
docker images
I see a list of images with their repository, tag, image id, created and virtual size.
I understand what image id and created are.
But what is the relationship between repository and tag?
And is the virtual size?
I went through the glossary on their website. But I couldn't find any information about this. The reason I ask is because when I do docker images I sometimes see the same image being listed more than once with the same image id but different tag.
Indeed, I found it confusing as well.
In a nutshell:
an image is uniquely defined by its id (a docker image is analogous to a git commit)
a given image may be tagged one or multiple times (just like git tags)
a repository is a set of images, to quote the documentation: "a repository is a hosted collection of tagged images that together create the file system for a container."
The git analogy might be useful to grasp this.
About the size: "size" is the size of the commit (eg: of the image), while virtual size is the cumulative size of all "previous" images this image is based upon (eg: "all previous commits"). Some info here: https://github.com/dotcloud/docker/pull/594 and https://github.com/dotcloud/docker/issues/22
Does it help?
Is it possible to do very basic image recognition to compare an image against a database of images(resource folder images or any web servers images if we have) and determine which image in the database is the best match? I don't need to do any processing of any of the images, but simply differentiate between a finite list of images.
Is it any open source code available ?
I would recommend using OpenCV if you simply want to compare images (i.e. decide if two images are the same).
Here is a similar question on SO:
iOS image comparison
I would also go about reading a little bit about what Core Image (the iOS image library) has to offer, before going about OpenCV or other 3rd party.
I hope this helps.