The first principle is that you must not fool yourself – and you are the easiest person to fool, Richard Feynman
We are going to custom Docker Image for KASM Workspaces, based on Ubuntu Core maintained by KASM Tech.
|
—Dockerfile
This is the file where you define the steps to build your Docker image. It includes instructions like which base image to use, which files to copy, and which commands to run.
—runlocally.sh
A script to automatize the building of your custom image and running it locally for testing
—— build
This directory contains additional resources, configuration files, or files that you want to include in your Docker image.
—wallpaper.png
An image file, which could be used as a wallpaper
—starship.toml # Configuration file for Starship, a cross-shell prompt.
—terminator.toml # Configuration file for Terminator, a terminal emulator.
FROM kasmweb/ubuntu-focal-desktop:1.15.0
USER root
ENV HOME /home/kasm-default-profile
ENV STARTUPDIR /dockerstartup
ENV INST_SCRIPTS $STARTUPDIR/install
WORKDIR $HOME
######### Customize Container Here ###########
# Install required packages
RUN apt-get update
RUN apt -y upgrade
RUN apt -y install openvpn gdebi gimp vlc synaptic libreoffice
RUN apt -y install unzip keepassxc fonts-roboto fonts-cascadia-code fonts-firacode dbus-x11 xfconf
# The background can be changed by overwriting the /usr/share/backgrounds/bg_default.png file.
COPY config/wallpaper.png /usr/share/backgrounds/bg_default.png
# Install Starship
RUN wget https://starship.rs/install.sh
RUN chmod +x install.sh
RUN ./install.sh -y
# Add Starship to bashrc
RUN echo 'eval "$(starship init bash)"' >> .bashrc
# Add Starship Theme
COPY config/starship.toml $ENV_CONFIG/starship.toml
# Install Hack Nerd Font
RUN wget https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/Hack.zip
RUN unzip Hack.zip -d /usr/local/share/fonts
# Install XFCE Dark Theme
RUN apt -y install numix-gtk-theme
Next we will utilize the custom_startup.sh interface point to set the GTK theme to Numix and the icon theme to Numix for the XFCE desktop environment when the session starts. Create the script and mark it executable. This script will run in the standard user (1000) context when the session starts. Utilize the built-in command /usr/bin/desktop_ready to ensure firefox starts after the Kasm desktop environment.
RUN echo "/usr/bin/desktop_ready && xfconf-query -c xsettings -p /Net/ThemeName -s 'Numix' && xfconf-query -c xsettings -p /Net/IconThemeName -s 'Numix'" > $STARTUPDIR/custom_startup.sh \
&& chmod +x $STARTUPDIR/custom_startup.sh
######### End Customizations ###########
RUN chown 1000:0 $HOME
RUN $STARTUPDIR/set_user_permission.sh $HOME
ENV HOME /home/kasm-user
WORKDIR $HOME
RUN mkdir -p $HOME && chown -R 1000:0 $HOME
USER 1000
Step 1. Build your custom Docker image: docker build -t nmaximo7/myctperdocker:latest .
Step 2. To run this custom image in a local environment start the docker container with the following command, and connect to your machine on https://localhost:6901 and log in with username kasm_user and password password.
docker run --rm -it --shm-size=512m -p 6901:6901 -e VNC_PW=password nmaximo7/myctperdocker:latest
docker run starts a new container from the specified image.
‐‐rm automatically removes the container when it exits.
-it allows you to interact with the container via the command line.
‐‐shm-size=512m sets the size of the shared memory to 512 megabytes.
-p 6901:6901 maps port 6901 on your host to port 6901 on the container, making it accessible from your host machine.
-e VNC_PW=password sets an environment variable VNC_PW inside the container with the value password (log in without introducing KASM credentials).
nmaximo7/myctperdocker:latest specifies the image to use (nmaximo7/myctperdocker) and the tag (latest), which typically points to the most recent version of the image.
Step 3. Next, connect to your machine on https://localhost:6901 and log in with username kasm_user and password password.
#!/bin/bash
docker build -t nmaximo7/myctperdocker:latest .
docker run --rm -it --shm-size=512m -p 6901:6901 -e VNC_PW=password nmaximo7/myctperdocker:latest
sleep 2
firefox https://localhost:6901
There are several ways to remove all Docker containers, depending on whether you want to remove only stopped containers or all containers (including running ones).
docker rm $(docker ps -aq)
docker rm -f $(docker ps -aq)
, -f forces the removal of running containers.docker ps
. Stop the Container using the docker stop command docker stop [CONTAINER_ID]
. Since we have used the –rm option, the container will be removed automatically after it stops.❯ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c779bcbef821 nmaximo7/myctperdocker:latest "/dockerstartup/kasm…" 22 minutes ago Up 22 minutes 4901/tcp, 5901/tcp, 0.0.0.0:6901->6901/tcp, :::6901->6901/tcp inspiring_clarke
nmaximo7 on nixos dotfiles/scripts on main [✘!?]
❯ docker stop inspiring_clarke
inspiring_clarke
First, you need to create an account to Docker Hub
nmaximo7 on nixos customdocker/myctperdocker/ubuntuxfc on main [✘!?]
❯ docker login
# Introduce your credentials
nmaximo7 on nixos customdocker/myctperdocker/ubuntuxfc on main [✘!?] took 4s
❯ docker push nmaximo7/myctperdocker:latest
# Push your docker image to DockerHub
Register the image in Kasm by creating a new Workspace pointing to the docker image.
nmaximo7/myctperdocker:latest
.