Last active
October 19, 2017 08:57
-
-
Save trastle/798bfcbbd43a0c0162c9cdc18c4b1a9b to your computer and use it in GitHub Desktop.
Create a Docker container which runs the CMD as a limited user but also allow that user access to become root using sudo. Useful for our internal container manager which only allows access to running containers service user.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:xenial | |
RUN apt-get update && \ | |
apt-get -y --no-install-recommends upgrade && \ | |
rm -rf /var/lib/apt/lists/* | |
# Create a limited user, allow sudo access (requiring a password) and set an encrypted password for the user. | |
# Password hash created using: | |
# $ mkpasswd -m sha-512 -S saltsalt -s <<< pa$$w0rd | |
RUN addgroup limited-user && \ | |
adduser --system -gid 1000 limited-user && \ | |
usermod -p '$6$saltsalt$xzjaZOYawx.Y3cAmj0pmAXjaj7649kiuKFuYSdjRuvxatA1QcXiiybXrqGf4iLUKNnB5i0TPCgwo4kcjHUrO/0' limited-user && \ | |
echo "limited-user ALL=(ALL:ALL) ALL" >> /etc/sudoers | |
USER limited-user | |
CMD ["bash"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment