Skip to content

Instantly share code, notes, and snippets.

@mnebuerquo
Last active April 18, 2018 21:13
Show Gist options
  • Save mnebuerquo/f14821e4ed674ea9202f69c0f24b4595 to your computer and use it in GitHub Desktop.
Save mnebuerquo/f14821e4ed674ea9202f69c0f24b4595 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Install docker on machine, add a user to the docker group.
# first, find out if we're sudo
if [ $(id -u) -ne 0 ]; then
echo "Nope. Simon didn't say so.";
exit 1;
fi
# name of new user is our only argument
NEWUSER="$1"
# get docker from official repo
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-cache policy docker-ce
apt-get install -y docker-ce
# we want docker-compose too
curl -L https://github.com/docker/compose/releases/download/1.21.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
# anyone in a group named docker can use docker without sudo
groupadd docker
# add the new user if a name was given
if [ ! -z "${NEWUSER}" ]; then
# new user will not have password login, assume key based ssh
# or log in as a different user and sudo to this one.
adduser --disabled-password --gecos "" "${NEWUSER}"
gpasswd -a "${NEWUSER}" docker
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment