I'm trying to extend a docker container for SOLR. I just want to install vim
into it. But when I run the docker build it complains that I'm not root.
This is the DockerFile that I'm extending: https://github.com/makuk66/docker-solr/blob/master/5.3/Dockerfile
And my build file is this:
FROM makuk66/docker-solr MAINTAINER OCSCommerce Team <[email protected]> RUN apt-get update RUN apt-get --assume-yes install vim COPY home/ocscommerce /etc/solr/home
Then it outputs this:
192.168.99.100 localhost:solr$ docker build -t ocscommerce/solr . Sending build context to Docker daemon 39.66 MB Step 0 : FROM makuk66/docker-solr ---> 92be2fe79f15 Step 1 : MAINTAINER OCSCommerce Team <[email protected]> ---> Using cache ---> a3ac70e40324 Step 2 : RUN apt-get update ---> Running in c865716a2694 E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied) E: Unable to lock directory /var/lib/apt/lists/ E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied) E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
Is there any way to install a package into this container? Or would I need to copy the original build file from makuk66?
Rootless mode allows running the Docker daemon and containers as a non-root user to mitigate potential vulnerabilities in the daemon and the container runtime. Rootless mode does not require root privileges even during the installation of the Docker daemon, as long as the prerequisites are met.
To install packages in a docker container, the packages should be defined in the Dockerfile. If you want to install packages in the Container, use the RUN statement followed by exact download command . You can update the Dockerfile with latest list of packages at anytime and build again to create new image out of it.
Switch to the root
user, then switch back to the original solr
user:
USER root install/updates USER solr
Similar suggestion to the previous answer https://stackoverflow.com/a/37615312/2200690, open an interactive shell as the root user and then install your packages using apt-get.
docker exec --user="root" -it <container_name> /bin/bash
install the package
apt-get install package
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With