Docker Build

by abielicki
14 deployments · 4 still active · last rev. 27 days ago

Just a clean 64-bit Docker CE build with the options I needed to get it setup. This is IPv4 & IPv6 on Debian 9.

Compatible with: Debian 9
						#!/bin/bash
# <UDF name="HOSTNAME"  Label="Hostname" />
# <UDF name="DOMAIN"    Label="Domain Name">
# <UDF name="USERNAME"  Label="Account Username">
# <UDF name="USERPASS"  Label="Account Password">
# <UDF name="USERPUBKEY"    Label="Account Public Key">

source <ssinclude StackScriptID="1">

IPADDR=$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)
IPADDR6=$(ip addr show eth0 | grep -E "inet6.*?global" | awk '{print $2}' | cut -d/ -f1)

apt-get update && apt-get -y upgrade
apt-get install -q -y \
     apt-transport-https \
     ca-certificates \
     curl \
     gnupg2 \
     software-properties-common \
     vim-nox \
     sudo \
     net-tools \
     dnsutils

# Basics
ssh_disable_root
system_set_hostname "$HOSTNAME"
system_add_host_entry "$IPADDR" "$HOSTNAME $HOSTNAME.$DOMAIN"
system_add_host_entry "$IPADDR6" "$HOSTNAME $HOSTNAME.$DOMAIN"

user_add_sudo "$USERNAME" "$USERPASS"
user_add_pubkey "$USERNAME" "$USERPUBKEY"

service sshd restart
ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime

# Install Docker
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -

add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
   stable" \
   && apt-get update -q -y

apt-get install docker-ce -q -y

usermod -aG docker $USERNAME

sed -i "s/#PasswordAuthentication yes/PasswordAuthentication no/" /etc/ssh/sshd_config

shutdown -r now