JustToThePoint English Website Version
JustToThePoint en español
Colaborate with us

Build a custom image with Kasm

The first principle is that you must not fool yourself – and you are the easiest person to fool, Richard Feynman

Topology and Limits

We are going to custom Docker Image for KASM Workspaces, based on Ubuntu Core maintained by KASM Tech.

  1. Docker is a software platform designed to make it easier to create, deploy, and run applications by using containers. It offers OS-level virtualization to deliver software in packages called containers.
  2. KASM Tech offer a range of containerized apps, desktop environments, and core images that are open-source and customizable for different use cases

Structure

| —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

Test this image locally

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

Step 3. Next, connect to your machine on https://localhost:6901 and log in with username kasm_user and password password.

image info

Automatizing everything

#!/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

Killing the container

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).

  1. This is the safest option, as it doesn’t affect any running containers: docker rm $(docker ps -aq)
  2. Remove all containers (including running ones): docker rm -f $(docker ps -aq), -f forces the removal of running containers.
  3. Find the Container ID: 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

Pushing your image to DockerHub

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 your custom image

Register the image in Kasm by creating a new Workspace pointing to the docker image.

Bitcoin donation

JustToThePoint Copyright © 2011 - 2025 Anawim. ALL RIGHTS RESERVED. Bilingual e-books, articles, and videos to help your child and your entire family succeed, develop a healthy lifestyle, and have a lot of fun. Social Issues, Join us.

This website uses cookies to improve your navigation experience.
By continuing, you are consenting to our use of cookies, in accordance with our Cookies Policy and Website Terms and Conditions of use.