How can I create a Docker image from ISO? - docker

Unfortunately, I'm in an environment where I have to use CentOS 4.8 for business reasons.
I'd like to create an image in Docker to manage this horrible old version of OS.
I checked that some users put the image on the Docker Hub, and I checked that some images are working normally.
And the question here is, how did they create these images? Is it possible to create an image by ISO itself, or by other means, rather than an image derived from the official image distributed by Docker? (Official image exists from CentOS 5 version onwards)
and I've found that I can extract Ubuntu images from ISO through searching.
However, there is no talk of CentOS and RHEL clone OSs.
Thank you.

Related

Are official centos-atomic or centos-minimal docker images available?

I've seen that Red Hat have their own registry to make available RHEL atomic and minimal docker images.
Are there equivalent CentOS images publically available? I wasn't able to find any on Docker Hub or the Project Atomic downloads.
With Red Hat Universal Base Image being made available I'd assume that is now their solution to my question since it can be used without a RHEL subscription.
However, it does seem that you need a RHEL subscription to install additional packages onto the base images.

Minimal Ubuntu docker image is claimed to be 29MB, so why does "docker images" command say 84.1MB?

https://blog.ubuntu.com/2018/07/09/minimal-ubuntu-released
says
The 29MB Docker image for Minimal Ubuntu 18.04 LTS serves as a highly
efficient container...
...
On Dockerhub, the new Ubuntu 18.04 LTS image is now the new Minimal
Ubuntu 18.04 image. Launching a Docker instance with docker run
ubuntu:18.04 therefore launches a Docker instance with the latest
Minimal Ubuntu.
I ran the exact command mentioned:
docker run ubuntu:18.04
Then I ran "docker images" which said:
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu 18.04 16508e5c265d 5 days ago 84.1MB
Why does that output say 84.1MB? The Ubuntu web page I quoted says it should be 29MB.
Am I doing something wrong?
Am I measuring the size incorrectly?
How can I get an Ubuntu image that's only 29MB?
The article states that Docker Hub hosts a "standard" image, which is bigger than the cloud image. The cloud image is the new thing they introduced and it weighs 29MB while the standard image weighs 32MB.
The cloud image is not available on Docker Hub.
But still, where did the 84MB come from? It's because you are downloading a compressed image from the registry. Which, in this case, only weighs 32MB. Once downloaded, it's decompressed into its usable format and stored locally on your machine.
Meaning everything is in order. Where do you get that cloud image from? Well, I'd start by looking at:
[...] are available for use now in Amazon EC2, Google Compute Engine (GCE) [...]
If you'd like to use it with a private cloud, this is where you download the image from link to Ubuntu Minimal Cloud Images
-edit-
addressing your comment, those private cloud sizes may vary. This is at least partially, if not mostly, due to differences between various hypervisor stacks. As is hinted at in the article:
Cloud images also contain the optimised kernel for each cloud and supporting boot utilities.
--
Just as an update, these days (~three years later), the latest 18:04 image weighs 25MB in its compressed format, so the exact numbers from my original answer are no longer valid, but the point is still valid.

Is it necessary to have an base OS for docker image?

I am using Windows OS but to use docker I use CentOS VM over Oracle VM Virtualbox. I have seen a Dockerfile where centos is used as base image. First line of my Dockerfile is
FROM centos
If I check the Dockerfile of CentOS on Docker Hub then first line is
FROM scratch
scratch is used to build an explicitly empty image, especially for building images. Here I can understand that if I start traversing upward using "FROM " line then finally I will end up at "scratch" image. I can see that scratch can be used to create a minimal container.
Question: If I want to create some bigger applications using web server, database etc, then is it necessary to add a base OS image?
I have tried to search for mysql and tomcat and noticed that it finally uses a OS image.
My understanding of Container was that I can "just bundle the required software and my service" in the container. Please clarify.
Your understanding is correct, however "just bundle the required software and my service" may be cumbersome, especially if you also have some shell scripts that make further use of other support programs.
Using some base image that contains already all the necessary stuff is more convenient. You can share the same base image for several services and due to docker's layered images will have no overhead regarding disk space.

Docker images layers built on different platforms consider different

I've noticed that the same docker images built on different platforms (OS where docker engine running) are different. For example, I used to build a heavy docker image on travis CI (ubuntu), then pull it to my local machine (macos) and when I build the image (no modifications) on my mac, it just re-used image layers from the downloaded image. It's no longer the case now, now it builds another image from the scratch. I've looked it up under docker images and saw that it switched the tag between two images built on ubuntu and macos.
Did they change it? Are docker images built on different platforms no longer compatible?
P.S. Using the same docker version (docker-ce 17.06.2)

What is the practical use of a "tag" in docker?

For instance, there is one repository created using
$ docker tag friendlyhello john/get-started:part1
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
friendlyhello latest d9e555c53008 3 minutes ago 195MB
john/get-started part1 d9e555c53008 3 minutes ago 195MB
Now here are two images: friendlyhello:latest and john/get-started:part1.
I noticed that these two images has the same IMAGE ID.
So I guess there is just ONE image file on my disk.
If it is true, why should I tag to the repository just like create a link file in operating system?
In short, tags are used for convenience in order to identify an image (which is a combination of filesystem layers). Because your image evolves over time and sees more layers being added to form a new image, tags are also a convenient way to do versioning.
When a user downloads your image from a registry like Docker Hub or the Google Container Registry, they can easily associate which version they are downloading from the tag.
It is no different than tagging a release with git if you are familiar with it but you are tracking changes to your image in this case. You tag a release for your image and push changes to your remote repository.
Taking Ubuntu as an example, tags are used to refer to specific releases of the operating system and there can be plenty. For example these are all valid tags for Ubuntu (see docker hub's page):
rolling
zesty
17.04
latest
xenial
16.04
trusty
14.04
Multiple tags can point to one container image. With Ubuntu: xenial, latest and 16.04 are tags that point to the same location, these are just many ways to refer to the same image. This way and because I know that the latest (stable) version of Ubuntu is xenial and the version number is 16.04, I can download this specific image from the Docker Hub using either of these terms or tags.
In the same way trusty and xenial do not point to the same image. They point to images that may have common filesystem layers but diverged at some point.
You can tag images to make sure you will be able to find them later. If you store an image only with latest its probable you'll overwrite it on the next build and then potentially delete it with docker prune which deletes all images that are not referenced.a

Resources