This can be used to retreive files/binaries/information from docker containers.
#!/bin/bash
set -Eeuo pipefail
mkdir ./binary || true
# build most recent docker image
docker build --pull -t <image_name> .
# disable entrypoint
# keep the container alive
docker run --rm -d -v $PWD/binary:/binary --name=<container_name> --entrypoint="" <image_name> sh -c "while true; do sleep 1; done" || true
# remove old files
docker exec <container_name> rm -rf /binary/*
# get binary version
docker exec <container_name> sh -c '<some_binary> -V > /binary/version.txt 2>&1'
# get release information
docker exec <container_name> sh -c 'cat /etc/os-release > /binary/system.txt'
# get dependencies
docker exec <container_name> sh -c 'ldd $(command -v <some_binary>) > /binary/dependencies.txt'
# get binary
docker exec <container_name> cp /usr/sbin/<some_binary> /binary/
# force remove the container again
docker container rm -f <container_name>