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
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
otherwise you cannot find anything...
You can use docker commit:
sudo docker run IMAGE_NAME
sudo docker exec -it CONTAINER_ID bash
sudo docker commit CONTAINER_ID NEW_IMAGE_NAME
If you run now
docker images
, you will seeNEW_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
A slight variation of the steps suggested by Arye that worked better for me:
docker run -it IMAGE_NAME bin/bash
exit
docker ps -a
and copy the ID of the container just modifieddocker 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
.