ttyrec is easy to install in many platforms
Use it inside the container, to produce the output file in a volume, and then use ttyrec to produce a GIF from the host.
docker run --rm -it -v `pwd`:/opt/recordings ubuntu:latest
apt update
apt install ttyrec
cd /opt/recordings
ttyrec my_session
# hack hack hack
exit
exit
in the host, use ttygif
sudo apt install ttygif
ttygif my_session
If using kitty terminal, there's no window decoration (the opposite of Konsole for example).