1

To speed up builds, I'd like to avoid install tools that I need on every commit with apt-get update -y && apt-get install -y git zip.

Normal way is to create custom build image, register at Docker Hub and upload it there. But I am 100% sure that there is already an up to date image that contains both git and zip tools that I need. The only question is how to find this image?

UPDATE 202004: There is no indexer for DockerHub, and there is no even indexer for Docker image contents. To start with that one could get a list of files from an image by patching dive by @wagoodman, or using https://github.com/GoogleContainerTools/container-diff

2

I can answer half of your question: If you have a set of images you're trying to investigate, the best way would be to use which in a new container using the image in question. This way you can quickly see if a particular image has the binaries your are looking for already on PATH:

docker run --rm ubuntu:latest which zip git
# no result

docker run --rm ubuntu:latest which bash sh
/bin/bash
/bin/sh
# ^-- both bash and sh are in the image

I don't know of a way to discover the set of images in question, as there is no manifest of files that a registry will provide. That is, yes, an image is a set of tar files, which you can extract a set of files/directory names... however, you'd still need to pull the entire image to get this information, so it would be easier to run the which command above.

There are tools for exploring information that a registry exposes (skopeo, doocker-ls, reg, manifest-tool, etc) but none of them will do exactly what you're looking for, which is "find a repository within a registry which contains an image that has a particular binary in it".

| improve this answer | |
  • Thanks for the answer. I did some research as well and came to the same conclusion - that there are tools that can look into images and even extract separate layers. With the tool that can extract the merged image cake building a searchable index for top 100 images will not be hard, but for now there is no solution. – Anatoli Babenia Feb 10 at 12:29
0

There are several options:

  • The first one is like you mentioned, creating an image yourself, push it to dockerhub and run docker run yourimage git etc.
  • Another option is to use an image that has already been published like this one. One could run it by issuing:

    docker run dockerinpractice/docker-dev-tools-image git
    
  • A third option is to add git to an existing image by using a Dockerfile:

    FROM alpine/git:1.0.7
    
    RUN apk add --update zip
    

Personally I wonder whether docker is the right tool for the job in this case.

| improve this answer | |
  • Still no answer how to find images like dockerinpractice/docker-dev-tools-image. This one is 4 years old and might have security issues. – Anatoli Babenia Dec 22 '19 at 16:25
0

If you have don't want to push your images to docker.com, are on an isolated network, or if you are doing this kind of thing regularly, you could consider setting up your own local docker registry. Doing this would

Setting up a docker registry is not a trivial task, you can find detailed instructions for setting up a docker registry at docker.com, but here is a brief summary:

  1. Get/run the docker registry image (yes, the registry will run inside docker):

    docker run -d -p 5000:5000 --restart=always --name registry registry:2

  2. build your image or use an existing one:

    docker tag ubuntu:16.04 localhost:5000/my-ubuntu

  3. Push this image to your logcal registry:

    docker push localhost:5000/my-ubuntu

Once you do this, you will be able to treat this local registry like Docker Hub; you could delete your "local" copy of this ubuntu image, then pull it down from your local repository again:

docker image remove ubuntu:16.04
docker image remove localhost:5000/my-ubuntu
docker pull localhost:5000/my-ubuntu
| improve this answer | |
  • Do you know if I can index files inside these Docker images? – Anatoli Babenia Dec 25 '19 at 11:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.