From 3b634a67e2b8edd2ed3a65ed51119325d41d0e73 Mon Sep 17 00:00:00 2001 From: Thorsten Spille Date: Fri, 18 Feb 2022 16:51:28 +0100 Subject: [PATCH] Create docker --- plugins/docker | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 plugins/docker diff --git a/plugins/docker b/plugins/docker new file mode 100644 index 0000000..26d69b3 --- /dev/null +++ b/plugins/docker @@ -0,0 +1,58 @@ +#!/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 +zfs create -o com.sun:auto-snapshot=false -o mountpoint=/var/lib/docker $ZPOOL/docker +zfs create -o com.sun:auto-snapshot=true -o mountpoint=/portainer $ZPOOL/portainer + +# 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 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