Homepage dashboard trong Docker: gom dịch vụ HomeLab ở cổng 8006
MỤC LỤC BÀI VIẾT (Nhấn để xem)
Homepage là dashboard tĩnh, nhanh và tùy biến để gom các dịch vụ HomeLab. Tutorial i12bretro dùng Docker, lưu cấu hình ở ~/homepage và cấp Docker socket để Homepage tự phát hiện container bằng labels.1
Cài Docker
Đăng nhập Linux Docker host rồi chạy block sau:
# install prerequisites
sudo apt install apt-transport-https ca-certificates curl software-properties-common gnupg-agent -y
# add docker gpg key
curl -fsSL https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release)/gpg | sudo apt-key add -
# add docker software repository
sudo add-apt-repository "deb [arch=$(dpkg --print-architecture)] https://download.docker.com/linux/$(awk -F'=' '/^ID=/{ print $NF }' /etc/os-release) $(lsb_release -cs) stable"
# install docker
sudo apt install docker-ce docker-compose containerd.io -y
# enable and start docker service
sudo systemctl enable docker && sudo systemctl start docker
# add the current user to the docker group
sudo usermod -aG docker $USER
# reauthenticate for the new group membership to take effect
su - $USER
Chạy Homepage
Nguồn yêu cầu xem UID/GID trước, tạo thư mục cấu hình và chạy container. Giữ nguyên id $user của source; nếu shell không có biến chữ thường này, mình dừng để kiểm tra biến trước, không thay mù trong lệnh nguồn:
# list current uid and gid, note these for later
id $user
# make a homepage directory to mount in the container
mkdir ~/homepage -p
# run the homepage docker image
# replace PUID, GUID with the output of the id $user command above
docker run -d --name=homepage -e PUID=1000 -e PGID=1000 -p 8006:3000 -v ~/homepage:/app/config -v /var/run/docker.sock:/var/run/docker.sock --restart unless-stopped ghcr.io/benphelps/homepage
Mở http://DNSorIP:8006. Cổng host 8006 map vào cổng container 3000; config được giữ ở ~/homepage.
Quyền của Docker socket
Bind /var/run/docker.sock cho phép Homepage đọc/trao đổi với Docker daemon, nên đây là quyền nhạy cảm. Mình không public port 8006 không có authentication, giới hạn mạng quản trị và backup ~/homepage trước khi sửa YAML. Nếu chỉ cần dashboard tĩnh, cân nhắc không mount socket và cấu hình thủ công.
Nguồn
https://i12bretro.github.io/tutorials/0859.html — i12bretro tutorial 0859. ↩︎