Make sure you understand the security implications before enabling sudo
in your Docker images.
RUN apt-get update -y && \
DEBIAN_FRONTEND=noninteractive apt-get install -y sudo && \
rm -rf /var/lib/apt/lists
RUN echo 'pwuser ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers
↑ Replace pwuser
with the name of the user you want to enable sudo
for.