skip to Main Content

i’ve been using a docker container to build the chromium browser (building for Android on Debian 10). I’ve already created a Dockerfile that contains most of the packages I need.

Now, after building and running the container, I followed the instructions, which asked me to execute an install script (./build/install-build-deps-android.sh). In this script multiple apt install commands are executed.

My question now is, is there a way to install these packages without rebuilding the container? Downloading and building it took rather long, plus rebuilding a container each time a new package is required seems kind of suboptimal. The error I get when executing the install script is:

./build/install-build-deps-android.sh: line 21: lsb_release: command not found

(I guess there will be multiple missing packages). And using apt will give:

root@677e294147dd:/android-build/chromium/src# apt install nginx
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package nginx

(nginx just as an example install).

I’m thankfull for any hints, as I could only find guides that use the Dockerfile to install packages.

3

Answers


  1. Chosen as BEST ANSWER

    Thanks for @adnanmuttaleb and @David Maze (unfortunately, they only replied, so I cannot accept their answers).

    What I did was to edit the Dockerfile for any later updates (which already happened), and use the exec command to install the needed dependencies from outside the container. Also remember to

    apt update
    

    otherwise you cannot find anything...


  2. You can use docker commit:

    1. Start your container sudo docker run IMAGE_NAME
    2. Access your container using bash: sudo docker exec -it CONTAINER_ID bash
    3. Install whatever you need inside the container
    4. Exit container’s bash
    5. Commit your changes: sudo docker commit CONTAINER_ID NEW_IMAGE_NAME

    If you run now docker images, you will see NEW_IMAGE_NAME listed under your local images.

    Next time, when starting the docker container, use the new docker image you just created:
    sudo docker run **NEW_IMAGE_NAME** – this one will include your additional installations.

    Answer based on the following tutorial: How to commit changes to docker image

    Login or Signup to reply.
  3. A slight variation of the steps suggested by Arye that worked better for me:

    1. Create container from image and access in interactive mode: docker run -it IMAGE_NAME bin/bash
    2. Modify container as desired
    3. Leave container: exit
    4. List launched containers: docker ps -a and copy the ID of the container just modified
    5. Save to a new image: docker commit CONTAINER_ID NEW_IMAGE_NAME

    If you haven’t followed the Post-installation steps for Linux
    , you might have to prefix Docker commands with sudo.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search