I'm trying to install nano , and when using the apt-get install nano command inside the docker, it asks to use the super user:
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?
And when trying to use sudo he says it doesn't exist
bash: sudo: command not found
Most docker containers doesn't provide sudo util. If you need some software in your container you may create your images based on another that you need with installing necessary software by describing in dockerfile.
Also you may install sudo in your custom image.
For docker you need to test each command as running on the local host machine, you have many tools already installed, and the Docker images you have the minimum required usually, so only what is required is installed, and the docker image size can be small also.
Either have a look at what software is installed on the Docker image already using the command compgen -c and then install the software you would require which is not installed, or run your software and see if you receive errors or software not being found, and then install the software required.
Try this:
docker exec -u root -it <your_container_name> bash
and then apt-get install nano.
Related
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.
You can use docker commit:
Start your container sudo docker run IMAGE_NAME
Access your container using bash: sudo docker exec -it CONTAINER_ID bash
Install whatever you need inside the container
Exit container's bash
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
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...
A slight variation of the steps suggested by Arye that worked better for me:
Create container from image and access in interactive mode: docker run -it IMAGE_NAME bin/bash
Modify container as desired
Leave container: exit
List launched containers: docker ps -a and copy the ID of the container just modified
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.
Sorry for basic Question, as I am new on Docker and I want to install the dependencies by using the docker file, So please guide me how to run this file on Ubuntu?
Author have written the dependencies in the Dockerfile for building the Opensfm.
GitHub Repository Link
FROM ubuntu:18.04
# Install apt-getable dependencies
RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get update \
&& apt-get install -y \
build-essential \
Can anyone guide me how to run the file and install the dependencies on Ubuntu?
You really should follow mchawre's advice and read the docker get-started. However, I can try to direct you into the right direction.
I want to install the dependencies by using the docker file
You have to understand that a docker file compiles to a docker image which then can be run as a docker container. You can think of a docker container as a lightweight virtual machine. With this in mind, your statement does not make sense, since you can not install dependencies for your host system (the system in which you might want to start the docker container) with the help of a docker image. This is not how docker containers are supposed to work.
Instead, the docker file allows you to create a virtualized (isolated) environment in which you can ssh (the docker way: docker exec -it <container_name> bash) and then build the respective application.
If you do not want to mess with docker at all and your systems runs something close to ubuntu:18.04, you can also manually execute the instruction from the docker file on your normal system in order to build your desired application on your system.
I am completely new to docker. I have a Redhat 7 desktop with docker installed.
I now want to run a full fledged ubuntu-desktop 18.04 (including its gnome GUI) via docker. How can this be done? I have been googling for instructions/tutorials on where I can download an ubuntu 18.04 docker image (with GUI support) and run it, but surprisingly I cannot find anything. Can someone help me? Thanks.
I have a different situation, where I run docker on a Windows10 platform. I also tried to install Gnome for some Ubuntu image and start a gnome-session from the terminal. I did not manage to do so.
My current solution is to use Mate instead of Gnome. Maybe my steps are helpful for others that just started with docker:
Install Docker Desktop on Windows 10 and start the Docker application
Install vcxsrv and start it with Xlaunch (also see https://dev.to/darksmile92/run-gui-app-in-linux-docker-container-on-windows-host-4kde)
Get the IP of your computer with ipconfig, e.g 192.111.999.9
Open a console with admin rights and start a docker container. Pass some DISPLAY-Information including your IP:
docker run -it -e DISPLAY=192.111.999.9:0.0 --privileged --name=ubuntu ubuntu
You should then see a linux prompt
Update the package-manager and upgrade existing packages:
apt-get update
apt-get upgrade -y
apt-get update
start dbus service to avoid dbus warnings (also see https://georgik.rocks/how-to-start-d-bus-in-docker-container/):
dbus-uuidgen > /var/lib/dbus/machine-id
mkdir -p /var/run/dbus
dbus-daemon --config-file=/usr/share/dbus-1/system.conf --print-address
install mate (and some themes to avoid theme warning)
apt-get install mate-desktop-environment -y
apt-get ubuntu-mate-themes -y
start a Desktop session with
mate-session
Good luck!
(If you want some more programs, instead of "mate-desktop-environment", you can also use the larger package "ubuntu-mate-desktop". Will take > 10 min to be installed.)
This is an atypical use case for Docker. Docker is normally used to run applications via the command line, or on a server without GUI support. Most operating systems in docker images ship without GUI support.
However, you can enable GUI support with X11. Only with containers that support it though, and not with Ubuntu as far as I can tell. More details on this blog post: https://blog.jessfraz.com/post/docker-containers-on-the-desktop/
For now, just run docker run -it --rm ubuntu:latest bash and you'll launch an Ubuntu 18.04 shell (at the time of this post).
If I do a docker command like
docker -version
I get the error that docker is not installed and that I can do sudo apt-get install docker to install it. If I do this, it says that docker is the latest version. Do I need to set some kind of path to the binary to get it to run?
If I do which docker, there is no answer.
I have found the answer to the question.
Apparently there is a package called "docker" which has nothing to do with docker the container software which is actually docker-ce. The application I had installed was the fake docker, not the container-ware.
To install docker-ce there is a process given on Digital Ocean which can be used.
.
I want to run an executable and all of its libraries from within my container. How do I do that?
For my Ubuntu 14.04 server, I can do sudo apt-get install tetex-base tetex-bin
In this case, however, someone already set up a docker container for me, and I need to be able to run the program from within the container.
I got it working with
docker exec -it containerName apt-get install tetex-base tetex-bin
See docs.