find base image or ''source in docker hub'' for an image in local - docker

The project I am working have its docker images built from
FROM java:8-jre
Now I am writing a new service and though I can also make java:8-jre base image for my service. But I wanted to find out from where it was taken at the first place. As on docker hub I see only openjdk or oracle one is available.
Also if I do like below it is downloaded from docker hub (I guess, As I tried on my local as well), But cant see it on dockerHub(why?)
docker pull java:8-jre
Is there any way, I can search this image at docker hub or find its source with something like below -
docker image inspect java:8-jre

This image belongs to the official java repository, which is deprecated in favor of openjdk repository.
Accessing this repo will redirect you to the openjdk page.
But you can have a glimpse of java repo page here.
You can still find the Dockerfile for your image here.

Information which you need will be available in Dockerfile for that particular image.
I didn't find any image with name java:8-jre in docker hub.
Closest which I found was
https://hub.docker.com/r/fiadliel/java8-jre/
To see steps of Dockerfile for that Image build try this
docker image history --no-trunc image_name > image_history

Related

Dockerfile FROM command - Does it always download from Docker Hub?

I just started working with docker this week and came across a 'dockerfile'. I was reading up on what this file does, and the official documentation basically mentions that the FROM keyword is needed to build a "base image". These base images are pulled from Docker hub, or downloaded from there.
Silly question - Are base images always pulled from docker hub?
If so and if I understand correctly I am assuming that running the dockerfile to create an image is not done very often (only when needing to create an image) and once the image is created then the image is whats run all the time?
So the dockerfile then can be migrated to which ever enviroment and things can be set up all over again quickly?
Pardon the silly question I am just trying to understand the over all flow and how dockerfile fits into things.
If the local (on your host) Docker daemon (already) has a copy of the container image (i.e. it's been docker pull'd) specified by FROM in a Dockerfile then it's cached and won't be repulled.
Container images include a tag (be wary of ever using latest) and the image name e.g. foo combined with the tag (which defaults to latest if not specified) is the full name of the image that's checked i.e. if you have foo:v0.0.1 locally and FROM:v0.0.1 then the local copy is used but FROM foo:v0.0.2 will pull foo:v0.0.2.
There's an implicit docker.io prefix i.e. docker.io/foo:v0.0.1 that references the Docker registry that's being used.
You could repeatedly docker build container images on the machines where the container is run but this is inefficient and the more common mechanism is that, once a container image is built, it is pushed to a registry (e.g. DockerHub) and then pulled from there by whatever machines need it.
There are many container registries: DockerHub, Google Artifact Registry, Quay etc.
There are tools other than docker that can be used to interact with containers e.g. (Red Hat's) Podman.

Docker Image history without using docker history command

I have a docker image. I want to analyze the docker image history, for this I can use docker image history command in the docker installed environment.
But when am working in a Openshift cluster, I may not have the access to the docker command here. So here I want get the docker history command result for the given image.
So basically I have a docker image and I don't have docker installed there. In this case how can we get the history of that docker image?
Can anyone please help me on this?
You can get the registry info either via curl or skopeo inspect. But the rest of the metadata is stored inside the image itself so you do have to download at least the final layer.

what does tomcat docker comes with by default?

I am fairly new to docker. I was looking into docker hub and found that there is a docker image for tomcat which can be downloaded using docker pull tomcat. So my question is how can I know what does this image contains. Is there an underlying OS and then tomcat is installed on top of it. how can I know all the details about the docker image?
As mentioned the link in the comment, visit the link and you will see everything in that Dockerfile.
So if you visit openjdk/Dockerfile you will see the list of packages and some base image.
Better to use that images from the Dockerhub which Dockerfile is given.
In simple word, your image only contains the OS or packages that are defined in Dockerfile.
This is the dockerfile that define every thing and the container will only contain that packages that are defined in Dockerfile. You should not ignore based image in Dockerfile too.

ubuntu-core as container os in base image

I'm currently reviewing possible solutions for container operation systems for our applications. I'm considering RancherOS and Ubuntu-Core. But since we are using docker base images, I'm a little confused how to create a docker base image with ubuntu-core. I can't find an official release candidate from canonical and I don't want to create it myself from a tag. How could I compose the base image?
I can't find an official release candidate from canonical
Yes, there is no officaial image on dockerhub, but this & some other high pull images are good to use I think.
How could I compose the base image
If you still do not want to use the images on docker hub. Then in fact you still can form your own docker image based on official ubuntu-core release like next:
Download Ubuntu Core based on 14.04 version
wget http://cdimage.ubuntu.com/ubuntu-core/trusty/daily/current/trusty-core-ppc64el.tar.gz
Import the files into docker
# cat trusty-core-ppc64el.tar.gz | docker import - ubuntucore
3ad6c6616b921b10a414238a226fb39eef85d8249ac7d767e84e275aaf90ab65
Guarantee that the image was created:
# docker images
Assure that your image is running fine:
# docker run ubuntucore ls
Detail refers to IBM guide, and, if you need to use the new version, you also can find it in http://cdimage.ubuntu.com/ubuntu-core

How can I find the images being pulled from the SHA1s?

When we run a docker container if the relevant image is not in the local repo it is being downloaded but in a specific sequence i.e parent images etc.
If I don’t know anything about the image how could I find from which images is being based on based on the layers pulled as displayed in a docker run?
The output only shows the SHA1s on any docker run etc
AFAIK, you can't, there is no reverse function for a hash.
Docker just tries to get the image from local, when its not available tries to fetch it from the registry. The default registry is DockerHub.
When you don't specify any tag when running the container ie: docker run ubuntu instead of docker run ubuntu:16.04 the default latest is used. You'll have to visit the registry and search which version the latest tag is pointing to.
Usually in DockerHub there is a link pointing the GitHub repo where you can find the Dockerfile, in the Dockerfile you can find how its built, including the root image.
You also can get some extra info with docker image inspect image:tag, but you'll find more hashes in the layers.
Take a look to dockerfile-from-image
"Similar to how the docker history command works, the dockerfile-from-image script is able to re-create the Dockerfile (approximately) that was used to generate an image using the metadata that Docker stores alongside each image layer."
With this, maybe you can get the source of the image.

Resources