Last active
May 7, 2022 04:48
-
-
Save elifiner/f1e19b49bf65369b82bc9d6734abc16d to your computer and use it in GitHub Desktop.
Set up a bare Ubuntu box to run a Docker
This file contains 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
#!/bin/bash | |
# This script should set up a bare Ubuntu box (like the one in DigitalOcean) | |
# with everything needed to run a Docker-based environment. | |
# | |
# To set up a fresh box, login as root and run: | |
# | |
# $ curl https://gist.githubusercontent.com/elifiner/f1e19b49bf65369b82bc9d6734abc16d/raw | sh - | |
USER=eli | |
DOCKER_COMPOSE_VERSION=1.29.2 | |
# create user and set up ssh and sudo | |
adduser --disabled-password --gecos "" $USER | |
adduser $USER sudo | |
mkdir /home/$USER/.ssh | |
cp .ssh/authorized_keys /home/$USER/.ssh | |
chown -R $USER:$USER /home/$USER/.ssh | |
chmod 640 /etc/sudoers | |
echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers | |
# install docker and dependencies | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | |
apt-get update | |
apt-get install apt-transport-https ca-certificates curl software-properties-common unzip | |
apt-get install linux-image-extra-virtual | |
apt-get install -y docker-ce | |
adduser $USER docker | |
# install docker-compose | |
sudo curl -o /usr/local/bin/docker-compose -L "https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" | |
sudo chmod +x /usr/local/bin/docker-compose |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment