my need is to install certain packages like ssh server while creating ubuntu container, any way to add a post create function or any way to use custom ubuntu image?
In 25.04.2.5: Apps → Discover Apps → … → Install via YAML. Post your docker compose, and you are good to go.
Also, this guide can be useful – Electric Eel - How I am using Dockerfile, .env files, compose files.
On second thought, it could be that you are asking about LXC…
My guess is that @ASWIN meant lxc container and not docker apps… and he meant to ask how to include extra packages when he spins up a new lxc and doesn’t have to install them manually after the lxc is set up…
This post includes some information on how to do it
The relevent part of the config file is (as an example):
Install apt repos and packages needed for docker
apt:
preserve_sources_list: true
sources:
docker.list:
source: deb [arch=amd64] https://download.docker.com/linux/debian $RELEASE stable
keyid: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
filename: docker.list
nvidia-container-toolkit.list:
source: deb https://nvidia.github.io/libnvidia-container/stable/deb/$(ARCH) /
keyid: C95B321B61E88C1809C4F759DDCAE044F796ECB0
filename: nvidia-container-toolkit.list
packages:
- apt-transport-https
- apt-utils
- ca-certificates
- curl
- gpg
- docker-ce
- docker-ce-cli
- containerd.io
- docker-buildx-plugin
- docker-compose-plugin
- nvidia-container-toolkit
Edit:
your workflow would most likely be to create the container, stop it after it’s installed.
Edit the config file with
sudo incus config edit <contairnename>
and add the packages you want to be installed, and then start the container again.