How to stop apt-get using /tmp for install scripts
Solution 1:
I added the code from this post in the script which (insert pipeline orchestrator) runs to pull the base image and install the image-specific software.
Because the script had been using sudo, and because by default this does not adopt the root account, running sudo adopted the default ubuntu user so it sets up the tmp file in the wrong place and doesn't work. Because apt-get
needs root to run it, I added this to ensure only root could run my script:
if [[ ${EUID} -ne 0 ]]; then
echo "This script must be run as root" 1>&2
exit 1
fi
I then removed the sudo prefix to the commands in my bash script, and ran the whole script with an sudo to make the orchestrator run my script as the root user, which meant the orchestrator created the tmp file correctly on the build machine.
Credence to @djdomi.