NocoBase搭建(上):环境搭建

发布于:2024-12-18 ⋅ 阅读:(47) ⋅ 点赞:(0)

用了一段时间Appsmith, 感觉低代码比写代码开发还麻烦,于是继续找其它低代码平台,突然发现了一个免代码的NocoBase,看起来非常不错,于是用一台虚拟机先搭建Docker环境安装NocoBase。
Nocobase的支持三种安装方式:
1.Docker(推荐)
2.create-nocobase-app
3.Git 源代码

一.安装虚拟机操作系统
安装Debian 12,配置IP地址,卸载冲突的组件。
root@Nocobase:~#for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done
# Add Docker's official GPG key:
root@Nocobase:~# apt-get update
root@Nocobase:~#apt-get install ca-certificates curl
root@Nocobase:~# install -m 0755 -d /etc/apt/keyrings
root@Nocobase:~#curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
root@Nocobase:~#chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/debian \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

二.安装Docker
root@Nocobase:~# sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following package was automatically installed and is no longer required:
  libdbus-glib-1-2
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
  docker-ce-rootless-extras git git-man iptables liberror-perl libip6tc2 libslirp0 patch pigz slirp4netns
Suggested packages:
  aufs-tools cgroupfs-mount | cgroup-lite git-daemon-run | git-daemon-sysvinit git-doc git-email git-gui gitk gitweb git-cvs
  git-mediawiki git-svn firewalld ed diffutils-doc
The following NEW packages will be installed:
  containerd.io docker-buildx-plugin docker-ce docker-ce-cli docker-ce-rootless-extras docker-compose-plugin git git-man iptables
  liberror-perl libip6tc2 libslirp0 patch pigz slirp4netns
0 upgraded, 15 newly installed, 0 to remove and 1 not upgraded.
Need to get 133 MB of archives.
After this operation, 493 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Ign:1 https://download.docker.com/linux/debian bookworm/stable amd64 containerd.io amd64 1.7.23-1
Get:2 https://download.docker.com/linux/debian bookworm/stable amd64 docker-buildx-plugin amd64 0.17.1-1~debian.12~bookworm [30.3 MB]
Get:3 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 pigz amd64 2.6-1 [64.0 kB]
Get:4 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 libip6tc2 amd64 1.8.9-2 [19.4 kB]
Get:5 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 iptables amd64 1.8.9-2 [360 kB]
Get:6 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 liberror-perl all 0.17029-2 [29.0 kB]
Get:7 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 git-man all 1:2.39.5-0+deb12u1 [2,054 kB]
Get:8 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 git amd64 1:2.39.5-0+deb12u1 [7,256 kB]
Get:9 https://download.docker.com/linux/debian bookworm/stable amd64 docker-ce-cli amd64 5:27.3.1-1~debian.12~bookworm [15.0 MB]
Get:10 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 libslirp0 amd64 4.7.0-1 [63.0 kB]
Get:11 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 patch amd64 2.7.6-7 [128 kB]
Get:12 https://mirrors.tuna.tsinghua.edu.cn/debian bookworm/main amd64 slirp4netns amd64 1.2.0-1 [37.5 kB]
Get:13 https://download.docker.com/linux/debian bookworm/stable amd64 docker-ce amd64 5:27.3.1-1~debian.12~bookworm [25.6 MB]
Get:14 https://download.docker.com/linux/debian bookworm/stable amd64 docker-ce-rootless-extras amd64 5:27.3.1-1~debian.12~bookworm [9,587 kB]
Get:15 https://download.docker.com/linux/debian bookworm/stable amd64 docker-compose-plugin amd64 2.29.7-1~debian.12~bookworm [12.7 MB]
Get:1 https://download.docker.com/linux/debian bookworm/stable amd64 containerd.io amd64 1.7.23-1 [29.5 MB]
Fetched 133 MB in 3s (44.1 MB/s)
Selecting previously unselected package pigz.
(Reading database ... 146562 files and directories currently installed.)
Preparing to unpack .../00-pigz_2.6-1_amd64.deb ...
Unpacking pigz (2.6-1) ...
Selecting previously unselected package containerd.io.
Preparing to unpack .../01-containerd.io_1.7.23-1_amd64.deb ...
Unpacking containerd.io (1.7.23-1) ...
Selecting previously unselected package docker-buildx-plugin.
Preparing to unpack .../02-docker-buildx-plugin_0.17.1-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-buildx-plugin (0.17.1-1~debian.12~bookworm) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../03-docker-ce-cli_5%3a27.3.1-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-ce-cli (5:27.3.1-1~debian.12~bookworm) ...
Selecting previously unselected package libip6tc2:amd64.
Preparing to unpack .../04-libip6tc2_1.8.9-2_amd64.deb ...
Unpacking libip6tc2:amd64 (1.8.9-2) ...
Selecting previously unselected package iptables.
Preparing to unpack .../05-iptables_1.8.9-2_amd64.deb ...
Unpacking iptables (1.8.9-2) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../06-docker-ce_5%3a27.3.1-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-ce (5:27.3.1-1~debian.12~bookworm) ...
Selecting previously unselected package docker-ce-rootless-extras.
Preparing to unpack .../07-docker-ce-rootless-extras_5%3a27.3.1-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-ce-rootless-extras (5:27.3.1-1~debian.12~bookworm) ...
Selecting previously unselected package docker-compose-plugin.
Preparing to unpack .../08-docker-compose-plugin_2.29.7-1~debian.12~bookworm_amd64.deb ...
Unpacking docker-compose-plugin (2.29.7-1~debian.12~bookworm) ...
Selecting previously unselected package liberror-perl.
Preparing to unpack .../09-liberror-perl_0.17029-2_all.deb ...
Unpacking liberror-perl (0.17029-2) ...
Selecting previously unselected package git-man.
Preparing to unpack .../10-git-man_1%3a2.39.5-0+deb12u1_all.deb ...
Unpacking git-man (1:2.39.5-0+deb12u1) ...
Selecting previously unselected package git.
Preparing to unpack .../11-git_1%3a2.39.5-0+deb12u1_amd64.deb ...
Unpacking git (1:2.39.5-0+deb12u1) ...
Selecting previously unselected package libslirp0:amd64.
Preparing to unpack .../12-libslirp0_4.7.0-1_amd64.deb ...
Unpacking libslirp0:amd64 (4.7.0-1) ...
Selecting previously unselected package patch.
Preparing to unpack .../13-patch_2.7.6-7_amd64.deb ...
Unpacking patch (2.7.6-7) ...
Selecting previously unselected package slirp4netns.
Preparing to unpack .../14-slirp4netns_1.2.0-1_amd64.deb ...
Unpacking slirp4netns (1.2.0-1) ...
Setting up libip6tc2:amd64 (1.8.9-2) ...
Setting up liberror-perl (0.17029-2) ...
Setting up docker-buildx-plugin (0.17.1-1~debian.12~bookworm) ...
Setting up containerd.io (1.7.23-1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/containerd.service → /lib/systemd/system/containerd.service.
Setting up patch (2.7.6-7) ...
Setting up docker-compose-plugin (2.29.7-1~debian.12~bookworm) ...
Setting up docker-ce-cli (5:27.3.1-1~debian.12~bookworm) ...
Setting up libslirp0:amd64 (4.7.0-1) ...
Setting up pigz (2.6-1) ...
Setting up git-man (1:2.39.5-0+deb12u1) ...
Setting up docker-ce-rootless-extras (5:27.3.1-1~debian.12~bookworm) ...
Setting up slirp4netns (1.2.0-1) ...
Setting up iptables (1.8.9-2) ...
update-alternatives: using /usr/sbin/iptables-legacy to provide /usr/sbin/iptables (iptables) in auto mode
update-alternatives: using /usr/sbin/ip6tables-legacy to provide /usr/sbin/ip6tables (ip6tables) in auto mode
update-alternatives: using /usr/sbin/iptables-nft to provide /usr/sbin/iptables (iptables) in auto mode
update-alternatives: using /usr/sbin/ip6tables-nft to provide /usr/sbin/ip6tables (ip6tables) in auto mode
update-alternatives: using /usr/sbin/arptables-nft to provide /usr/sbin/arptables (arptables) in auto mode
update-alternatives: using /usr/sbin/ebtables-nft to provide /usr/sbin/ebtables (ebtables) in auto mode
Setting up docker-ce (5:27.3.1-1~debian.12~bookworm) ...
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 git (1:2.39.5-0+deb12u1) ...
Processing triggers for man-db (2.11.2-2) ...
Processing triggers for libc-bin (2.36-9+deb12u9) ...

三.测试Docker
root@Nocobase:~# docker run hello-world
Unable to find image 'hello-world:latest' locally
docker: Error response from daemon: Get "https://registry-1.docker.io/v2/": net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers).
See 'docker run --help'.
root@Nocobase:~#
root@Nocobase:~# systemctl start docker
Job for docker.service failed because the control process exited with error code.
See "systemctl status docker.service" and "journalctl -xeu docker.service" for details.
root@Nocobase:~# journalctl -xeu docker.service
░░ The unit docker.service has entered the 'failed' state with result 'exit-code'.
Nov 17 08:55:00 Nocobase systemd[1]: Failed to start docker.service - Docker Application Container Engine.
░░ Subject: A start job for unit docker.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit docker.service has finished with a failure.
░░
░░ The job identifier is 2208 and the job result is failed.
Nov 17 08:55:03 Nocobase systemd[1]: docker.service: Scheduled restart job, restart counter is at 3.
░░ Subject: Automatic restarting of a unit has been scheduled
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ Automatic restarting of the unit docker.service has been scheduled, as the result for
░░ the configured Restart= setting for the unit.
Nov 17 08:55:03 Nocobase systemd[1]: Stopped docker.service - Docker Application Container Engine.
░░ Subject: A stop job for unit docker.service has finished
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A stop job for unit docker.service has finished.
░░
░░ The job identifier is 2310 and the job result is done.
Nov 17 08:55:03 Nocobase systemd[1]: docker.service: Start request repeated too quickly.
Nov 17 08:55:03 Nocobase systemd[1]: docker.service: Failed with result 'exit-code'.
░░ Subject: Unit failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ The unit docker.service has entered the 'failed' state with result 'exit-code'.
Nov 17 08:55:03 Nocobase systemd[1]: Failed to start docker.service - Docker Application Container Engine.
░░ Subject: A start job for unit docker.service has failed
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit docker.service has finished with a failure.
░░
░░ The job identifier is 2310 and the job result is failed.

四.Docker失败问题解决
自己刚才只是新建过Daemon.json,问题应该是出在这个上面。删除后重启,Docker运行正常。
root@Nocobase:/etc/docker# rm daemon.json
root@Nocobase:/etc/docker# systemctl restart docker
root@Nocobase:/etc/docker# systemctl status docker
● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled)
     Active: active (running) since Sun 2024-11-17 09:01:21 CST; 6s ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 1374 (dockerd)
      Tasks: 10
     Memory: 40.5M
        CPU: 523ms
     CGroup: /system.slice/docker.service
             └─1374 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

Nov 17 09:01:20 Nocobase dockerd[1374]: time="2024-11-17T09:01:20.451659837+08:00" level=info msg="[graphdriver] using prior storage >
Nov 17 09:01:20 Nocobase dockerd[1374]: time="2024-11-17T09:01:20.459203832+08:00" level=info msg="Loading containers: start."
Nov 17 09:01:21 Nocobase dockerd[1374]: time="2024-11-17T09:01:21.088052799+08:00" level=info msg="Default bridge (docker0) is assign>
Nov 17 09:01:21 Nocobase dockerd[1374]: time="2024-11-17T09:01:21.157785551+08:00" level=info msg="Loading containers: done."
Nov 17 09:01:21 Nocobase dockerd[1374]: time="2024-11-17T09:01:21.189231529+08:00" level=warning msg="WARNING: bridge-nf-call-iptable>
Nov 17 09:01:21 Nocobase dockerd[1374]: time="2024-11-17T09:01:21.189263429+08:00" level=warning msg="WARNING: bridge-nf-call-ip6tabl>
Nov 17 09:01:21 Nocobase dockerd[1374]: time="2024-11-17T09:01:21.189292129+08:00" level=info msg="Docker daemon" commit=41ca978 cont>
Nov 17 09:01:21 Nocobase dockerd[1374]: time="2024-11-17T09:01:21.189889329+08:00" level=info msg="Daemon has completed initializatio>
Nov 17 09:01:21 Nocobase dockerd[1374]: time="2024-11-17T09:01:21.237580196+08:00" level=info msg="API listen on /run/docker.sock"
Nov 17 09:01:21 Nocobase systemd[1]: Started docker.service - Docker Application Container Engine.

重新创建daemon.json
root@Nocobase:/etc/docker# touch daemon.json
root@Nocobase:/etc/docker# vi daemon.json
{
  "registry-mirrors":
    [
      "https://docker.m.daocloud.io/",
      "https://huecker.io/",
    ]
}
重启
root@Nocobase:/etc/docker# systemctl restart docker
测试
root@Nocobase:/etc/docker# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:305243c734571da2d100c8c8b3c3167a098cab6049c9a5b066b6021a60fcb966
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/