【问题标题】:Failed to build node app on Dokku running as a Docker image on Macos在 Macos 上作为 Docker 映像运行的 Dokku 上构建节点应用程序失败
【发布时间】:2022-01-28 21:15:58
【问题描述】:

我已按照原始文档中的步骤在 Macos 上部署 Dokku 的 Docker 映像:

docker run \
    --env DOKKU_HOSTNAME=dokku.me \
    --name dokku \
    --publish 3022:22 \
    --publish 8080:80 \
    --publish 8443:443 \
    --volume /var/lib/dokku:/mnt/dokku \
    --volume /var/run/docker.sock:/var/run/docker.sock \
    dokku/dokku:latest

来源:https://hub.docker.com/r/dokku/dokku

然后我在容器中初始化了 ssh-keys,并按照建议为主机名 dokku.me 创建了一个别名。现在我可以连接到 Dokku 容器并在其上运行命令,例如创建一个新应用程序:

dokku apps:create node-test
dokku git:initialize node-test

我已经在我的节点项目中添加了一个新的遥控器并尝试推送:

git remote add dokku dokku@dokku.me:node-test

但是推送失败并出现我完全不理解的错误:

➜  node-test git:(node-test) git push dokku master
Enumerating objects: 27, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 16 threads
Compressing objects: 100% (19/19), done.
Writing objects: 100% (27/27), 2.95 KiB | 301.00 KiB/s, done.
Total 27 (delta 4), reused 3 (delta 0), pack-reused 0
-----> Cleaning up...
-----> Building node-test from herokuish
-----> Setting config vars
       CURL_CONNECT_TIMEOUT:  90
-----> Setting config vars
       CURL_TIMEOUT:  600
-----> Adding BUILD_ENV to build environment...
       BUILD_ENV added successfully
remote: Error response from daemon: Mounts denied:
remote: The path /home/dokku/node-test/cache is not shared from the host and is not known to Docker.
remote: You can configure shared paths from Docker -> Preferences... -> Resources -> File Sharing.
remote: See https://docs.docker.com/docker-for-mac for more info.
remote: Error: failed to start containers: c1ab941dcf71650f99c3199546277ec333463a09695d0dcf1cac755d3ec7bacf
remote: You cannot attach to a stopped container, start it first
remote: 2022/01/27 15:48:15 exit status 1
To dokku.me:node-test
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'dokku.me:node-test'

在我的 Mac 文件系统中创建此文件夹后,我已从 Docker Desktop 更新了文件共享选项并添加了 /var/lib/dokku

➜  node-test git:(node-test) ls -al /var/lib/dokku
total 0
drwxr-xr-x  2 root  wheel   64 Jan 27 14:22 .
drwxr-xr-x  4 root  wheel  128 Jan 27 14:22 ..

我怀疑它与 Docker 主机中挂载的文件夹有关,但我无法弄清楚它到底是什么。

Macos 版本 12.01

独孤版

root@b6df7b8bc9b0:/tmp# dokku version
dokku version 0.26.7

Docker 版本:

➜  node-test git:(node-test) docker version
Client: Docker Engine - Community
 Cloud integration: 1.0.12
 Version:           20.10.5
 API version:       1.41
 Go version:        go1.13.15
 Git commit:        55c4c88
 Built:             Tue Mar  2 20:13:00 2021
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.5
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       363e9a8
  Built:            Tue Mar  2 20:15:47 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

【问题讨论】:

    标签: node.js macos docker dokku


    【解决方案1】:

    我再次检查了 v0.26.7 的 Docker Installation Nodes 并注意到与 instructions from Dockerhub 相比,docker container run 有一个额外的参数:

    docker container create \
      --env DOKKU_HOSTNAME=dokku.me \
      --env DOKKU_HOST_ROOT=/var/lib/dokku/home/dokku \
      --name dokku \
      --publish 3022:22 \
      --publish 8080:80 \
      --publish 8443:443 \
      --volume /var/lib/dokku:/mnt/dokku \
      --volume /var/run/docker.sock:/var/run/docker.sock \
      dokku/dokku:0.26.7
    

    额外的参数--env DOKKU_HOST_ROOT=/var/lib/dokku/home/dokku 似乎解决了我的问题。

    现在推送到 Dokku 不会再抛出 Mounts denied 错误了。

    【讨论】:

      猜你喜欢
      • 2021-08-23
      • 2020-06-09
      • 2022-09-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多