3

I have a Dockerfile something like follows:

FROM openjdk:8u151

# others here

I have 2 questions about the base image:

1. How to get the tags?

Usually, I get it from dockerhub, let's say openjdk:8u151, I can get it from dockerhub's openjdk repository.

If I could get all tags from any local docker command, then I no need to visit web to get the tags, really a little low efficiency?

2. Will the base image safe?

I mean if my base image always there?

Look at the above openjdk repo, it is an offical repo.

I found there is only 8u151 left for me to choose. But I think there should be a lots of jdk8 release during the process, so should also a lots of jdk8 images there, something like 8u101, 8u163 etc.

So can I guess the maintainer will delete some old images for openjdk? Then if this happen, how my Dockerfile work? I should always change my base image if my upstream delete there image? Really terrible for me to maintain such kind of thing.

Even if the openjdk really just generate one release of jdk8. My puzzle still cannot be avoided, as dockerhub really afford the delete button for users.

What's the best practice, please suggest, thanks.

Community
  • 1
  • 1
atline
  • 28,355
  • 16
  • 77
  • 113

1 Answers1

3

How to get the tags?

See "How to list all tags for a Docker image on a remote registry?".
The API is enough

For instance, visit:

https://registry.hub.docker.com/v2/repositories/library/java/tags/?page_size=100&page=2

Will the base image safe?

As long as you save your own built image in a registry (eithe rpublic one, or a self-hosted one), yes: you will be able to at least build new images based on the one you have done.
Or, even if the base image disappears, you still have its layers in your own image, and can re-tag it (provided the build cache is available).
See for instance "Is there a way to tag a previous layer in a docker image or revert a commit?".
See caveats in "can I run an intermediate layer of docker image?".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 3
    Let me understand the `provided the build cache is available`. If I build my image on my pc, I can see `openjdk:8u151` image on my pc, then I can retag it even if the image on dockerhub was deleted. But, If I nolonger able to login my pc, I cannot retag the base layer, as with `docker pull` my old image, I cannot see `openjdk:8u151`, so I can nolonger build my image again (Of course I can still use my old image, but not able to build it again?) – atline Mar 18 '18 at 08:28
  • In the [arctical](https://stackoverflow.com/questions/38234611/is-there-a-way-to-tag-a-previous-layer-in-a-docker-image-or-revert-a-commit) you recommend, I see `What it means is that you won't have access to the build layers unless you built this image in the current machine or exported and loaded by combining:`, does this mean I need to reserve my build machine? – atline Mar 18 '18 at 08:38
  • @lagom Reserve your build machine or export your image, save as an archive (tar) somewhere, in order to preserve the layers. – VonC Mar 18 '18 at 10:09