Modifying a prebuilt Docker image

Hi

I am experimenting with trying to make custom builds using Docker, rather than the ‘traditional’ envsetup.sh, lunch, mka method. My problem is that the prebuilt Docker image is missing a python module (the requests module) that is needed to do the customising.

Before I start down the rabbit hole of building my own Docker image, does anyone here know if it possible to “patch” a prebuilt Docker image, to e.g. install a missing pyython module?

I’ve done a quick online search, and found a few promising links, but if anyone here can give me a shortcut, or tell me definitely it can’t be done, I would be very grateful

Thanks :pray:

import the current community Docker image in your own Dockerfile and install the missing package. Docker images are tarballed filesystem layers - it’s a minor addition. Anybody having the upstream image locally already can build it fast

FROM registry.gitlab.e.foundation:5000/e/os/docker-lineage-cicd:community AS cicd

RUN apt-get -qq update && apt-get install -y python3-requests

(current docker-lineage-cicd seems to use python3)

put this Dockerfile in its own folder and build with

docker build -t local/docker-lineage-cicd:community .

you can push it to a registry outside the local machine, but if you don’t use it often elsewhere there’s no reason to do so.

After doing the build reference it in your

docker run
  -e ..
  -v ..
  local/docker-lineage-cicd:community
3 Likes

Thanks - that’s really useful

I may try to build from source, as I want to use a different branch of the source than the one that is used to build the docker image that is pushed to Docker Hub. I imagine that will take a bit longer to build :slight_smile:

Having investigated some more, I realise that there is no need to modify the Docker image: I can install the python module I need in a userscript that is run before the build starts :slight_smile:

But I’ve learned a lot about how Docker and Docker Hub work, so the time has not been wasted

2 Likes