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).
Related
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.
I have two machines with different OS. One is ubuntu 18.04 and the other is debian buster. Both of them have docker installations ( from here ) and and the latest nvidia-docker installed. Both systems have a gpu which I want to use inside the containers. So I created a dockerfile which will install everything I require.
FROM ubuntu:18.04
RUN apt update -y
RUN apt upgrade -y
RUN apt install \
nvidia-cuda-toolkit \
-y
In the first machine which has as host ubuntu and a gpu that require .435 driver to work it works fine (docker run --rm --gpus all my-image:1 nvidia-smi)
But when I try the same dockerfile with 0 changes on my Debian machine it will return missmatched version of drivers.
The second matching which has as a host debian and a gpu that require .418 dirver to work it complains about missmatched versions.
Isn't supposed to be host independent installation ? What am I missing and I cannot build the same Dockerfile in both systems?
I can see toolkit bringing drivers on its own but as it is apt installation I have no control over it.
Thank you in advance
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.
To play around with a docker image, I installed docker and ran a sample docker ubuntu image as follows. (I hope I am using terminology correctly, still a docker noob)
docker run -it ubuntu
Because gvim or anyother gui based program was not installed, by default, I did, inside the ubuntu docker container
apt-get update
apt-get install x11-apps vim-gtk
However, on running xclock I get
root#59be2b1afca0:/# xclock
Error: Can't open display: :0
root#59be2b1afca0:/#
On running gvim I get
root#59be2b1afca0:/# gvim
E233: cannot open display
Press ENTER or type command to continue
So why won't gui apps work?
Containers weren't quite designed originally for gui apps, but rather for services, workers, processes, etc.. On the other hand since containerisation is a kernel construct to isolate and dedicate resources in a more managed way which can expose ports or share volumes, and devices etc..
This means you can technically map your screen, audio, webcam devices to a container by using --device /dev/xyz when you run your docker run command:
docker run [--rm [-it]|-d] \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY \
--device /dev/dri \
myimage [cmd]
I actually found an article describing this here - including audio, camera and other device mapping.
http://somatorio.org/en/post/running-gui-apps-with-docker/
Hope this helps a bit!
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.