在Raspberry Pi 2B上跑Docker, AdguardHome, Bitwarden, RPi-Monitor
請先參考前置準備工作安裝Raspberry Pi 2B 來跑docker 前置準備
安全性考量, 移除預設pi帳號
Ref :https://www.raspberrypi.org/documentation/linux/usage/users.md
https://www.raspberrypi.org/documentation/configuration/security.md
新增user, 移除預設pi
假設新user是homesrv
# Add new user homesrv, and setup homesrv to sudo group
sudo adduser homesrv
sudo adduser homesrv sudo
sudo usermod -a -G adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,gpio,i2c,spi alice
# Kill all process run with pi, and then remove pi
sudo pkill -u pi
sudo deluser -remove-home pi
安裝docker
Ref : https://withblue.ink/2019/07/13/yes-you-can-run-docker-on-raspbian.htmlTo install Docker CE on Raspbian Stretch and Buster:
# Install some required packages first
sudo apt update
sudo apt install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common
# Get the Docker signing key for packages
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg | sudo apt-key add -
# Add the Docker official repos
echo "deb [arch=armhf] https://download.docker.com/linux/$(. /etc/os-release; echo "$ID") \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
# Install Docker
# The aufs package, part of the "recommended" packages, won't install on Buster just yet, because of missing pre-compiled kernel modules.
# We can work around that issue by using "--no-install-recommends"
sudo apt update
sudo apt install -y --no-install-recommends \
docker-ce \
cgroupfs-mount
#starting Docker and enabling it at boot:
sudo systemctl enable docker
sudo systemctl start docker
#Test docker, it should show "Hello from Docker !"
sudo docker run --rm arm32v7/hello-world
#Installing Docker Compose
# Install required packages
sudo apt update
sudo apt install -y python3-pip libffi-dev
# Install Docker Compose from pip (using Python3)
# This might take a while
sudo pip3 install docker-compos
安裝Adguardhome
Ref : https://github.com/AdguardTeam/AdGuardHome/wiki/Raspberry-Pi# download AdGuard Home and unpack it
cd $HOME
wget https://static.adguard.com/adguardhome/release/AdGuardHome_linux_arm.tar.gz
tar xvf AdGuardHome_linux_arm.tar.gz
# install AdguardHome
cd AdGuardHome
sudo ./AdGuardHome -s install
# start service
sudo ./AdGuardHome -s start
# check web interface, default port is 3000
http://192.168.0.2:3000/
安裝bitwardenrs
Ref :https://github.com/dani-garcia/bitwarden_rs/wiki/Which-container-image-to-use
https://github.com/dani-garcia/bitwarden_rs/wiki/Starting-a-Container
# 因為我是用pi 2b, 所以image要用bitwardenrs/server:raspberry
# 建立一個資料夾, 讓bitwarden去掛載來存放資料
# bitwarden port預設是80/443, 可以透過-p 去做mapping, 這邊我們假設mapping到9999<>80
# restart policy, 我是選用, 會自動重啟, 但是如果超過10次fail, 就停止restart
# 也可以替換為, --restart=always, --restart=unless-stopped
# Docker restart policy, Ref : https://www.centos.bz/2017/01/docker-run-restart-policy/
mkdir /home/homesrv/bitwarden/
docker run -d --restart=on-failure:10 --name bitwarden -v /home/homesrv/bitwarden/:/data/ -p 9999:80 bitwardenrs/server:raspberry
安裝RPi-Monitor
Ref :https://atceiling.blogspot.com/2019/04/raspberry-pi-47-rpi-monitor.html
https://www.leowkahman.com/2016/03/19/disable-ipv6-raspberry-raspbian/
安裝RPi-Monitor
# RPi-Monitor 使用https的方式下載安裝,apt-get 預設不支援https,需要安裝 RPi-Monitor的公鑰來信任 RPi-Monitor 的儲存庫
sudo apt-get install dirmngr
sudo apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 2C0D3C0F
# 新增 RPi-Monitor 到儲存庫清單
sudo wget http://goo.gl/vewCLL -O /etc/apt/sources.list.d/rpimonitor.list
# 如果你的環境不支援IPV6, 請先disable IPV6
sudo nano /etc/sysctl.conf
add new line : net.ipv6.conf.all.disable_ipv6 = 1
save, exit
sudo sysctl -p
# 進行安裝
sudo apt-get update
sudo apt-get install rpimonitor
# 更新package, 增加自動更新
sudo /etc/init.d/rpimonitor update
sudo /etc/init.d/rpimonitor install_auto_package_status_update
# 重新啟動RPi-Monitor
sudo service rpimonitor restart
# check web interface, default port is 8888
http://192.168.0.2:8888/