Help with Kubernetes Pod YAML: Commands in args not executing automatically, how to do so by editing only the .yml file?

I’m having an issue with my Kubernetes Pod YAML file. The commands specified in the args section are not executing automatically when the Pod starts. Instead, I have to manually run these commands each time, which is time-consuming and distracting. Here’s my YAML file:

apiVersion: v1
kind: Pod
metadata:
  name: my-pod
  namespace: default
spec:
  nodeSelector:
    node.kubernetes.io/instance-type: nice-gpu-machine
  containers:
  - args:
    - -c
    - |
      apt-get update -y
      apt upgrade -y
      yes | unminimize
      apt-get install -y byobu wget curl git vim nano jq unzip bzip2 tar gzip tmux htop tree net-tools man-db
      apt update -y
      apt upgrade -y
      apt install -y software-properties-common
      add-apt-repository -y ppa:deadsnakes/ppa
      apt update -y
      apt upgrade -y
      apt install -y python3.11 python3.11-venv python3.11-dev python3.11-distutils
      apt-get update -y && apt-get install -y openssh-server
      sleep infinity
    command:
    - /bin/bash
    image: my-registry/my-image:latest
    imagePullPolicy: IfNotPresent
    name: app
    resources:
      limits:
        nvidia.com/gpu: 8
        hugepages-2Mi: 5120Mi
      requests:
        memory: 8000Mi
    volumeMounts:
      - mountPath: /checkpoints
        name: checkpoints-volume
      - mountPath: /code
        name: code-volume
      - mountPath: /data
        name: data-volume
      - name: dshm
        mountPath: /dev/shm
  restartPolicy: Never
  volumes:
  - name: checkpoints-volume
    persistentVolumeClaim:
      claimName: checkpoints-pvc
  - name: code-volume
    persistentVolumeClaim:
      claimName: code-pvc
  - name: data-volume
    persistentVolumeClaim:
      claimName: data-pvc
  - name: dshm
    emptyDir:
      medium: Memory

I have two questions:

  1. Is there anything wrong with my YAML file that’s preventing the args commands from executing automatically?
  2. If the YAML file is correct, would it be better to create a new Docker image with these commands pre-installed? If so, how should I approach this?

Any help or guidance would be greatly appreciated, but solution 1 is strongly prefered as 2 is complicated afaik/way more time consuming than updating one .yml file e.g., pushing img building it and it might be huge! Thank you!

cross: docker - Support with Kubernetes Pod YAML: Commands in args not executing automatically, how to do so by editing only the .yml file? - Stack Overflow