建立個(gè)人音樂網(wǎng)站(1):在云服務(wù)器上利用docker部署navidrome服務(wù)
記錄和分享個(gè)人制作過程,僅供參考。需要一點(diǎn)計(jì)算機(jī)相關(guān)專業(yè)或從業(yè)經(jīng)驗(yàn),各位酌情考慮。本文非廣告,審核請(qǐng)放過。
【云服務(wù)器的選擇】
購(gòu)買輕量應(yīng)用服務(wù)器即可,也可到某寶上購(gòu)買香港美國(guó)等境外服務(wù)器。境外服務(wù)器的優(yōu)點(diǎn)是不用實(shí)名制同時(shí)也便宜,但個(gè)人感覺安全性不強(qiáng)所以還是選用境內(nèi)大廠如TX。
注意事項(xiàng):
①需要實(shí)名制(根據(jù)頁面提示操作即可);
②選用“輕量應(yīng)用服務(wù)器”最低配置即可滿足需求;
③系統(tǒng)鏡像選擇Linux內(nèi)核系統(tǒng)比如ubuntu,這里選擇Ubuntu Server 20.04 LTS 64bit;
【登錄服務(wù)器并配置】
①登錄服務(wù)器
購(gòu)買成功后進(jìn)入控制臺(tái)->我的資源->輕量應(yīng)用服務(wù)器


②使用官方提供的網(wǎng)頁xshell登錄服務(wù)器

③配置(重要)
step1:安裝docker

命令輸入與結(jié)果:
lighthouse@VM-4-4-ubuntu:~$?sudo apt update
Hit:1 http://mirrors.tencentyun.com/ubuntu focal InRelease
Hit:2 http://mirrors.tencentyun.com/ubuntu focal-security InRelease
Hit:3 http://mirrors.tencentyun.com/ubuntu focal-updates InRelease
Reading package lists... Done
Building dependency tree? ? ? ?
Reading state information... Done
160 packages can be upgraded. Run 'apt list --upgradable' to see them.
lighthouse@VM-4-4-ubuntu:~$?sudo apt install docker
Reading package lists... Done
Building dependency tree? ? ? ?
Reading state information... Done
The following packages were automatically installed and are no longer required:
? dblatex dblatex-doc dh-strip-nondeterminism docbook-dsssl docbook-utils docbook-xml docbook-xsl dvisvgm dwz eatmydata fonts-gfs-baskerville
? fonts-gfs-porson fonts-lmodern libalgorithm-c3-perl libapache-pom-java libarchive-cpio-perl libarchive-zip-perl libauthen-sasl-perl
? libb-hooks-endofscope-perl libb-hooks-op-check-perl libcairo2 libclass-c3-perl libclass-c3-xs-perl libclass-data-inheritable-perl
? libclass-method-modifiers-perl libclass-xsaccessor-perl libcommons-logging-java libcommons-parent-java libdata-dump-perl libdata-optlist-perl libdatrie1
? libdebhelper-perl libdevel-callchecker-perl libdevel-caller-perl libdevel-globaldestruction-perl libdevel-lexalias-perl libdevel-stacktrace-perl
? libdist-checkconflicts-perl libdynaloader-functions-perl libeatmydata1 libemail-date-format-perl libencode-locale-perl libeval-closure-perl
? libexception-class-perl libfile-basedir-perl libfile-desktopentry-perl libfile-homedir-perl libfile-listing-perl libfile-mimeinfo-perl
? libfile-stripnondeterminism-perl libfile-which-perl libfont-afm-perl libfontbox-java libgraphite2-3 libharfbuzz-icu0 libharfbuzz0b libhtml-form-perl
? libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl
? libhttp-message-perl libhttp-negotiate-perl libio-html-perl libio-socket-ssl-perl libio-stringy-perl libipc-shareable-perl libipc-system-simple-perl
? libkpathsea6 liblog-dispatch-perl liblog-log4perl-perl libltdl-dev liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl
? libmime-charset-perl libmime-lite-perl libmime-types-perl libmodule-implementation-perl libmodule-runtime-perl libmro-compat-perl
? libnamespace-autoclean-perl libnamespace-clean-perl libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl libosp5 libostyle1c2
? libpackage-stash-perl libpackage-stash-xs-perl libpadwalker-perl libparams-classify-perl libparams-util-perl libparams-validationcompiler-perl
? libpdfbox-java libpixman-1-0 libptexenc1 libreadonly-perl libref-util-perl libref-util-xs-perl librole-tiny-perl libsgmls-perl libsombok3 libspecio-perl
? libsub-exporter-perl libsub-exporter-progressive-perl libsub-identify-perl libsub-install-perl libsub-name-perl libsub-override-perl libsub-quote-perl
? libsynctex2 libtcl8.6 libteckit0 libtexlua53 libtexluajit2 libthai-data libthai0 libtie-ixhash-perl libtimedate-perl libtk8.6 libtry-tiny-perl
? libunicode-linebreak-perl liburi-perl libvariable-magic-perl libwoff1 libwww-perl libwww-robotrules-perl libx11-protocol-perl libxcb-render0 libxcb-shm0
? libxcursor1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxss1 libxstring-perl libyaml-tiny-perl libzzip-0-13 lmodern openjade opensp
? perl-openssl-defaults preview-latex-style python3-importlib-metadata python3-jinja2 python3-json-pointer python3-jsonpatch python3-jsonschema
? python3-markupsafe python3-more-itertools python3-pyrsistent python3-zipp sgml-base sgml-data sgmlspl squashfs-tools t1utils tcl tcl8.6 teckit tex-common
? tex-gyre texlive texlive-base texlive-bibtex-extra texlive-binaries texlive-extra-utils texlive-fonts-recommended texlive-formats-extra
? texlive-lang-greek texlive-latex-base texlive-latex-extra texlive-latex-recommended texlive-pictures texlive-plain-generic texlive-science texlive-xetex
? tipa tk tk8.6 x11-xserver-utils xdg-utils xfonts-encodings xfonts-utils xml-core xmlto xsltproc
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
? wmdocker
The following NEW packages will be installed:
? docker wmdocker
0 upgraded, 2 newly installed, 0 to remove and 160 not upgraded.
Need to get 14.3 kB of archives.
After this operation, 58.4 kB of additional disk space will be used.
Do you want to continue? [Y/n]?Y
Get:1 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 wmdocker amd64 1.5-2 [13.0 kB]
Get:2 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 docker all 1.5-2 [1,316 B]
Fetched 14.3 kB in 0s (314 kB/s)? ?
Selecting previously unselected package wmdocker.
(Reading database ... 136570 files and directories currently installed.)
Preparing to unpack .../wmdocker_1.5-2_amd64.deb ...
Unpacking wmdocker (1.5-2) ...
Selecting previously unselected package docker.
Preparing to unpack .../archives/docker_1.5-2_all.deb ...
Unpacking docker (1.5-2) ...
Setting up wmdocker (1.5-2) ...
Setting up docker (1.5-2) ...
Processing triggers for man-db (2.9.1-1) ...
lighthouse@VM-4-4-ubuntu:~$?sudo apt install docker-compose
Reading package lists... Done
Building dependency tree? ? ? ?
Reading state information... Done
The following packages were automatically installed and are no longer required:
? dblatex dblatex-doc dh-strip-nondeterminism docbook-dsssl docbook-utils docbook-xml docbook-xsl dvisvgm dwz eatmydata fonts-gfs-baskerville
? fonts-gfs-porson fonts-lmodern libalgorithm-c3-perl libapache-pom-java libarchive-cpio-perl libarchive-zip-perl libauthen-sasl-perl
? libb-hooks-endofscope-perl libb-hooks-op-check-perl libcairo2 libclass-c3-perl libclass-c3-xs-perl libclass-data-inheritable-perl
? libclass-method-modifiers-perl libclass-xsaccessor-perl libcommons-logging-java libcommons-parent-java libdata-dump-perl libdata-optlist-perl libdatrie1
? libdebhelper-perl libdevel-callchecker-perl libdevel-caller-perl libdevel-globaldestruction-perl libdevel-lexalias-perl libdevel-stacktrace-perl
? libdist-checkconflicts-perl libdynaloader-functions-perl libeatmydata1 libemail-date-format-perl libencode-locale-perl libeval-closure-perl
? libexception-class-perl libfile-basedir-perl libfile-desktopentry-perl libfile-homedir-perl libfile-listing-perl libfile-mimeinfo-perl
? libfile-stripnondeterminism-perl libfile-which-perl libfont-afm-perl libfontbox-java libgraphite2-3 libharfbuzz-icu0 libharfbuzz0b libhtml-form-perl
? libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl
? libhttp-message-perl libhttp-negotiate-perl libio-html-perl libio-socket-ssl-perl libio-stringy-perl libipc-shareable-perl libipc-system-simple-perl
? libkpathsea6 liblog-dispatch-perl liblog-log4perl-perl libltdl-dev liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl
? libmime-charset-perl libmime-lite-perl libmime-types-perl libmodule-implementation-perl libmodule-runtime-perl libmro-compat-perl
? libnamespace-autoclean-perl libnamespace-clean-perl libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl libosp5 libostyle1c2
? libpackage-stash-perl libpackage-stash-xs-perl libpadwalker-perl libparams-classify-perl libparams-util-perl libparams-validationcompiler-perl
? libpdfbox-java libpixman-1-0 libptexenc1 libreadonly-perl libref-util-perl libref-util-xs-perl librole-tiny-perl libsgmls-perl libsombok3 libspecio-perl
? libsub-exporter-perl libsub-exporter-progressive-perl libsub-identify-perl libsub-install-perl libsub-name-perl libsub-override-perl libsub-quote-perl
? libsynctex2 libtcl8.6 libteckit0 libtexlua53 libtexluajit2 libthai-data libthai0 libtie-ixhash-perl libtimedate-perl libtk8.6 libtry-tiny-perl
? libunicode-linebreak-perl liburi-perl libvariable-magic-perl libwoff1 libwww-perl libwww-robotrules-perl libx11-protocol-perl libxcb-render0 libxcb-shm0
? libxcursor1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxss1 libxstring-perl libyaml-tiny-perl libzzip-0-13 lmodern openjade opensp
? perl-openssl-defaults preview-latex-style python3-jinja2 python3-json-pointer python3-jsonpatch python3-markupsafe sgml-base sgml-data sgmlspl
? squashfs-tools t1utils tcl tcl8.6 teckit tex-common tex-gyre texlive texlive-base texlive-bibtex-extra texlive-binaries texlive-extra-utils
? texlive-fonts-recommended texlive-formats-extra texlive-lang-greek texlive-latex-base texlive-latex-extra texlive-latex-recommended texlive-pictures
? texlive-plain-generic texlive-science texlive-xetex tipa tk tk8.6 x11-xserver-utils xdg-utils xfonts-encodings xfonts-utils xml-core xmlto xsltproc
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
? bridge-utils containerd dnsmasq-base docker.io pigz python3-cached-property python3-docker python3-dockerpty python3-docopt python3-texttable
? python3-websocket runc ubuntu-fan
Suggested packages:
? ifupdown aufs-tools cgroupfs-mount | cgroup-lite debootstrap docker-doc rinse zfs-fuse | zfsutils
The following NEW packages will be installed:
? bridge-utils containerd dnsmasq-base docker-compose docker.io pigz python3-cached-property python3-docker python3-dockerpty python3-docopt
? python3-texttable python3-websocket runc ubuntu-fan
0 upgraded, 14 newly installed, 0 to remove and 160 not upgraded.
Need to get 69.4 MB of archives.
After this operation, 336 MB of additional disk space will be used.
Do you want to continue? [Y/n]?Y
Get:1 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 pigz amd64 2.4-1 [57.4 kB]
Get:2 http://mirrors.tencentyun.com/ubuntu focal/main amd64 bridge-utils amd64 1.6-2ubuntu1 [30.5 kB]
Get:3 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 runc amd64 1.1.0-0ubuntu1~20.04.1 [3,892 kB]
Get:4 http://mirrors.tencentyun.com/ubuntu focal-security/main amd64 containerd amd64 1.5.9-0ubuntu1~20.04.4 [33.0 MB]
Get:5 http://mirrors.tencentyun.com/ubuntu focal-security/main amd64 dnsmasq-base amd64 2.80-1.1ubuntu1.5 [315 kB]
Get:6 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 python3-cached-property all 1.5.1-4 [10.9 kB]
Get:7 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 python3-websocket all 0.53.0-2ubuntu1 [32.3 kB]
Get:8 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 python3-docker all 4.1.0-1 [83.8 kB]
Get:9 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 python3-dockerpty all 0.4.1-2 [11.1 kB]
Get:10 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 python3-docopt all 0.6.2-2.2ubuntu1 [19.7 kB]
Get:11 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 python3-texttable all 1.6.2-2 [11.0 kB]
Get:12 http://mirrors.tencentyun.com/ubuntu focal/universe amd64 docker-compose all 1.25.0-1 [92.7 kB]
Get:13 http://mirrors.tencentyun.com/ubuntu focal-updates/universe amd64 docker.io amd64 20.10.12-0ubuntu2~20.04.1 [31.8 MB]
Get:14 http://mirrors.tencentyun.com/ubuntu focal-updates/main amd64 ubuntu-fan all 0.12.13ubuntu0.1 [34.4 kB]
Fetched 69.4 MB in 1s (66.2 MB/s)? ? ? ?
Preconfiguring packages ...
Selecting previously unselected package pigz.
(Reading database ... 136580 files and directories currently installed.)
Preparing to unpack .../00-pigz_2.4-1_amd64.deb ...
Unpacking pigz (2.4-1) ...
Selecting previously unselected package bridge-utils.
Preparing to unpack .../01-bridge-utils_1.6-2ubuntu1_amd64.deb ...
Unpacking bridge-utils (1.6-2ubuntu1) ...
Selecting previously unselected package runc.
Preparing to unpack .../02-runc_1.1.0-0ubuntu1~20.04.1_amd64.deb ...
Unpacking runc (1.1.0-0ubuntu1~20.04.1) ...
Selecting previously unselected package containerd.
Preparing to unpack .../03-containerd_1.5.9-0ubuntu1~20.04.4_amd64.deb ...
Unpacking containerd (1.5.9-0ubuntu1~20.04.4) ...
Selecting previously unselected package dnsmasq-base.
Preparing to unpack .../04-dnsmasq-base_2.80-1.1ubuntu1.5_amd64.deb ...
Unpacking dnsmasq-base (2.80-1.1ubuntu1.5) ...
Selecting previously unselected package python3-cached-property.
Preparing to unpack .../05-python3-cached-property_1.5.1-4_all.deb ...
Unpacking python3-cached-property (1.5.1-4) ...
Selecting previously unselected package python3-websocket.
Preparing to unpack .../06-python3-websocket_0.53.0-2ubuntu1_all.deb ...
Unpacking python3-websocket (0.53.0-2ubuntu1) ...
Selecting previously unselected package python3-docker.
Preparing to unpack .../07-python3-docker_4.1.0-1_all.deb ...
Unpacking python3-docker (4.1.0-1) ...
Selecting previously unselected package python3-dockerpty.
Preparing to unpack .../08-python3-dockerpty_0.4.1-2_all.deb ...
Unpacking python3-dockerpty (0.4.1-2) ...
Selecting previously unselected package python3-docopt.
Preparing to unpack .../09-python3-docopt_0.6.2-2.2ubuntu1_all.deb ...
Unpacking python3-docopt (0.6.2-2.2ubuntu1) ...
Selecting previously unselected package python3-texttable.
Preparing to unpack .../10-python3-texttable_1.6.2-2_all.deb ...
Unpacking python3-texttable (1.6.2-2) ...
Selecting previously unselected package docker-compose.
Preparing to unpack .../11-docker-compose_1.25.0-1_all.deb ...
Unpacking docker-compose (1.25.0-1) ...
Selecting previously unselected package docker.io.
Preparing to unpack .../12-docker.io_20.10.12-0ubuntu2~20.04.1_amd64.deb ...
Unpacking docker.io (20.10.12-0ubuntu2~20.04.1) ...
Selecting previously unselected package ubuntu-fan.
Preparing to unpack .../13-ubuntu-fan_0.12.13ubuntu0.1_all.deb ...
Unpacking ubuntu-fan (0.12.13ubuntu0.1) ...
Setting up python3-cached-property (1.5.1-4) ...
Setting up python3-texttable (1.6.2-2) ...
Setting up python3-docopt (0.6.2-2.2ubuntu1) ...
Setting up dnsmasq-base (2.80-1.1ubuntu1.5) ...
Setting up runc (1.1.0-0ubuntu1~20.04.1) ...
Setting up bridge-utils (1.6-2ubuntu1) ...
Setting up pigz (2.4-1) ...
Setting up containerd (1.5.9-0ubuntu1~20.04.4) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up python3-websocket (0.53.0-2ubuntu1) ...
update-alternatives: using /usr/bin/python3-wsdump to provide /usr/bin/wsdump (wsdump) in auto mode
Setting up python3-dockerpty (0.4.1-2) ...
Setting up ubuntu-fan (0.12.13ubuntu0.1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/ubuntu-fan.service → /lib/systemd/system/ubuntu-fan.service.
Setting up python3-docker (4.1.0-1) ...
Setting up docker.io (20.10.12-0ubuntu2~20.04.1) ...
Adding group `docker' (GID 120) ...
Done.
Created symlink /etc/systemd/system/multi-user.target.wants/docker.service → /lib/systemd/system/docker.service.
Created symlink /etc/systemd/system/sockets.target.wants/docker.socket → /lib/systemd/system/docker.socket.
Setting up docker-compose (1.25.0-1) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for dbus (1.12.16-2ubuntu2.2) ...
Processing triggers for systemd (245.4-4ubuntu3.15) ...
step2:創(chuàng)建navidrome數(shù)據(jù)文件夾

命令輸入與輸出結(jié)果(記住標(biāo)記紅色的輸出結(jié)果):
lighthouse@VM-4-4-ubuntu:~$?mkdir music
lighthouse@VM-4-4-ubuntu:~$?mkdir navidrome
lighthouse@VM-4-4-ubuntu:~$?pwd
lighthouse@VM-4-4-ubuntu:~$ cd music
lighthouse@VM-4-4-ubuntu:~/music$ pwd
/home/lighthouse/music
lighthouse@VM-4-4-ubuntu:~$ cd navidrome/
lighthouse@VM-4-4-ubuntu:~/navidrome$ pwd
/home/lighthouse/navidrome
step3:查看當(dāng)前用戶id

輸入與輸出結(jié)果(記住標(biāo)記紅色的輸出結(jié)果):
lighthouse@VM-4-4-ubuntu:~/navidrome$?id
uid=1001(lighthouse) gid=1001(lighthouse) groups=1001(lighthouse)】
注意也應(yīng)查看用戶屬組:
lighthouse@VM-4-4-ubuntu:~$?cat /etc/group | grep lighthouse
lighthouse:x:1001:lighthouse
step3:創(chuàng)建并配置docker-compose.yml?

實(shí)際配置:
version: "3"?
services:?
? navidrome:
? ? image: deluan/navidrome:latest?
? ? user: 1001:1001
? ? ports:
? ? ? - "4533:4533"
? ? restart: unless-stopped?
? ? environment:
? ? ? ND_SCANSCHEDULE: 1h
? ? ? ND_L0GLEVEL: info
? ? ? ND_SESSIONTIMEOUT: 24h
? ? ? ND_BASEURL: ""
? ? volumes:
? ? ? - "/home/lighthouse/navidrome:/data"
? ? ? - "/home/lighthouse/music:/music:ro"
ctrl+s 可以保存,然后 ctrl+x 退出。退出后用cat查看:

step3:?jiǎn)?dòng)docker

實(shí)際輸入與輸出結(jié)果:
lighthouse@VM-4-4-ubuntu:~$?sudo docker-compose up -d
Pulling navidrome (deluan/navidrome:latest)...
latest: Pulling from deluan/navidrome
59bf1c3509f3: Pull complete
7e375ac7a149: Pull complete
eac6eb0aa754: Pull complete
Digest: sha256:6d55f0d287c5125366758a1a78b34e1c1ce09b2e4456a94e8284ef88f925f93d
Status: Downloaded newer image for deluan/navidrome:latest
Creating lighthouse_navidrome_1 ... done
lighthouse@VM-4-4-ubuntu:~$?sudo docker ps
CONTAINER ID? ?IMAGE? ? ? ? ? ? ? ? ? ? ?COMMAND? ? ? ? ? ? CREATED? ? ? ? ?STATUS? ? ? ? ? ? ? ? ? ?PORTS? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?NAMES
66f2e06d97c8? ?deluan/navidrome:latest? ?"/app/navidrome"? ?7 minutes ago? ?Up 7 minutes (healthy)? ?0.0.0.0:4533->4533/tcp, :::4533->4533/tcp? ?lighthouse_navidrome_1
lighthouse@VM-4-4-ubuntu:~$?sudo docker update --restart=always 66f2e06d97c8
66f2e06d97c8
step4:放開4533端口

step5:訪問Navidrome頁面:“https://IP:端口號(hào)”

step6:創(chuàng)建管理員用戶

登錄成功:

到此搭建完成,后續(xù)上傳音樂即可。