ubuntu-docker

by jonascheng
6 deployments · 5 still active · last rev. 3 months ago

Compatible with: Ubuntu 16.04 LTS, Ubuntu 18.04 LTS
Includes: lib-16
						#!/bin/bash
#
# <UDF name="USERNAME"  Label="Username" />
# <UDF name="SSH_KEY"   Label="SSH Key" />
# <UDF name="SSH_PORT"   Label="SSH Port" />
#

source <ssinclude StackScriptID=46109>

export DEBIAN_FRONTEND=noninteractive

# basic
apt-get update
apt-get -y install aptitude
aptitude -y full-upgrade

ssh_disable_root

ssh_disable_password

user_add_sudo "$USERNAME" "password"

user_add_pubkey  "$USERNAME" "$SSH_KEY"

# replace default SSH port to 2686
sed -i -e "s/#Port 22/Port $SSH_PORT/g" /etc/ssh/sshd_config

service sshd restart

# uninstall old versions of docker
apt-get remove docker docker-engine docker.io

# install docker
apt-get -y install docker.io

# install docker-compose
curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

# add dearbnb to docker group
usermod -aG docker $USER

# start and automate docker
systemctl start docker
systemctl enable docker

# clean apt cache
apt-get clean