Unable to get my Docker image's base image - docker

I built a docker image with my on changes on top of a docker image from docker hub. Now I forgot the base image I used to build my image. Is it possible to find that?
I tried inspect and history but that did not give me the required information.

The most obvious answer is to check your Dockerfile if you stil have it.
FROM base-image:tag
Its probably not the case, so the best you can do is run
docker images - check when your image has been created and check all the images that were created before your image.

Related

Change logo for certain Docker hub repository [duplicate]

I create docker image of my application (songkong/songkong) but I notice it doesnt have an icon whereas many other docker images do, how do I add an icon to the docker image ?
(my docker image is available on docker hub)
Not all official images have an associated icon. For instance, adoptopenjdk.
An image like logstash would use a logo.png in the docker-library/docs repository.
docker-library/docs issue 1060 asked: How do you add the icon for an image on Docker Hub?
But... there does not seem to be any formal process associated to that.
Only to become an official image.

Does the parent image of a Docker image get implicitly pulled from its repository if you run an already-built docker image?

Does the parent image of a docker image, the image source that follows after "FROM" in your Dockerfile, also need to be pulled again if you pull and run that custom docker image which is already built and uploaded? Or is the parent image already embedded in the child docker image?
I am NOT talking about docker build step here, I am talking about just pulling the built image and running it in docker engine.
Edit: NOT talking about pulling manually, too. Just asking if the docker engine automatically pulls.
Edit: I believe the parent image is embedded. But some layer seems to be pulling from its parent image's repository in my test. Note that this is not conclusive. It may well be that the Dockerfile of the parent image is doing something that requires connection to its own repository.
It is part of the image you built so you don't need to pull it again in order to run the container using the built image
Answering my own question here.
A docker image can have multiple layers. If some images of the layers are not distributable, these layers won't be in your registry and they have to be pulled from their original location such as Windows base image from Microsoft Container Registry, etc...
If you want all base layers images to be pulled from your own registry, you have to configure it using
{
"allow-nondistributable-artifacts": ["myregistrydomain.com:5000"]
}
as per this article from docker.
Then when you build and push your image to that registry, it will include all base images - even non-distributable ones.

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.

can I use any docker image as a base image or is there a predefined base images?

If I want to build a docker image,
I need to base on a docker base image.
All the example I found are based on top of official images.
Can I base my image on other docker user images ?
The FROM line in your Dockerfile can point to any image. It may be an upstream image from the Docker hub, one on any other registry server including one you self host, or it may be another image you've built locally on your own docker build host. Lastly, it may be FROM scratch which starts without any base image, and is used by other base images at some point in their history.

Where to see the Dockerfile for a docker image?

Is there a way to see the Dockerfile that generated an image I downloaded, to use as a template for my own docker images?
Use
docker history --no-trunc IMAGE_NAME_OR_ID
This will show all commands run in the image building process in reverse order. It's not exactly a Dockerfile, but you can find all essential content.

Resources