Build a container with this Dockerfile to create a nice desktop with sudo privileges. It is based on the image consol/ubuntu-xfce-vnc. Centos and IceWM are also supported. See the consol docker hub.
Docker group:
- First, ensure you are in the group
dockerby checkingid -Gn. - To add yourself to the group:
sudo usermod -a -G docker ${USER}(you will need to log out and log back in to activate the new membership).
Volume:
- Use a new docker volume:
docker volume create vol-${USER} && export VOLUME="vol-${USER}" - Use your home directory:
export VOLUME="/home/${USER}"
Build container:
- Get your UID, using
id -uand GID, usingid -g - Edit the Dockerfile and put in your username, UID, and GID.
- Add packages if you want. This file downloads clion and installs it in /opt
- Build the container
$ docker build -t vnc-${USER} -f Dockerfile ./
Run your container:
-
First, find a number
Nthat is not used for a vnc server. -
Start the server with a docker volume
docker run --cap-add sys_ptrace -p 590<N>:5901 --name vnc-${USER} --mount source=${VOLUME},target=/home/${USER} -e VNC_PW=<your password> -e VNC_RESOLUTION=1280x1024 vnc-${USER} -
... or alternatively with a disk partition:
docker run --cap-add sys_ptrace -p 590<N>:5901 --name vnc-${USER} -v${VOLUME}:/home/${USER} -e VNC_PW=<your password> -e VNC_RESOLUTION=1280x1024 vnc-${USER} -
Connect using VNC client to port
590<N>with password<your password> -
Note that you are a sudo user so you can add packages, etc.
-
But if you find yourself adding lots of packages, then maybe you want to put them into the Dockerfile
Check on things:
- To see if your container is running:
docker ps -a | grep $USER - If you need to kill your container (say, because you really should have used a docker volume):
docker stop vnc-${USER} && docker rm vnc-${USER}This is preferred to just hittingctrl-cbecause it will recycle the vnc port you are using.