nasbeery/plugins/docker
Thorsten Spille 302a857328
Update docker
2022-03-20 15:38:49 +01:00

63 lines
1.7 KiB
Bash

#!/bin/bash
prog="$(basename "$0")"
usage() {
cat >&2 <<-EOF
usage: $prog [-h] [-Z POOL]
installs nasbeery onto your raspberry pi os
-Z POOL Name of the zpool to create (default: tank)
---------------------------------------------------------------------------
(C) 2022 nasbeery installer by bashclub (https://github.com/bashclub)
---------------------------------------------------------------------------
EOF
exit $1
}
ZPOOL=tank
while getopts "hZ:" opt; do
case $opt in
h) usage 0 ;;
Z) ZPOOL=$OPTARG ;;
*) usage 1 ;;
esac
done
shift $((OPTIND-1))
# create zfs filesystems
if [ ! $(zfs list $ZPOOL/docker) ]; then
zfs create -o com.sun:auto-snapshot=false -o mountpoint=/var/lib/docker $ZPOOL/docker
fi
if [ ! $(zfs list $ZPOOL/portainer) ]; then
zfs create -o com.sun:auto-snapshot=true -o mountpoint=/portainer $ZPOOL/portainer
fi
# add docker repository
apt-key adv --fetch-keys https://download.docker.com/linux/debian/gpg
echo "deb https://download.docker.com/linux/debian $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
# update package lists and install docker engine + docker-compose
apt update
DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt install -y -qq --no-install-recommends docker-ce docker-ce-cli containerd.io docker-compose
# install portainer
cd /portainer
mkdir -p data
cat << EOF > /portainer/docker-compose.yml
version: '3.2'
services:
portainer:
image: portainer/portainer-ce
ports:
- "9443:9443"
- "8000:8000"
volumes:
- /portainer/data:/data
- /var/run/docker.sock:/var/run/docker.sock
restart: always
EOF
# start portainer
docker-compose up -d