Bookmark

Homepage dashboard trong Docker: gom dịch vụ HomeLab ở cổng 8006

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

Youtube video player

Video gốc đã được kiểm tra bằng YouTube oEmbed; tôi dùng shortcode/player hiện có của site.2

Cài Docker

Đăng nhập Linux Docker host rồi chạy block sau:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
# 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, tôi dừng để kiểm tra biến trước, không thay mù trong lệnh nguồn:

1
2
3
4
5
6
7
# 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. Tôi 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


  1. https://i12bretro.github.io/tutorials/0859.html — i12bretro tutorial 0859. Tutorial được biên tập độc lập từ numbered HTML page; các đường dẫn, UID/GID, port và socket được giữ nguyên. ↩︎

  2. https://www.youtube.com/watch?v=BzjL3tZ-NQs — Running Homepage Application Dashboard Using Docker — i12bretro ↩︎


0 Bình luận

Góp Ý / Bình Luận / Đánh giá