[英]Failed to build node app on Dokku running as a Docker image on Macos
I've followed the steps from original documentation to deploy a Docker image of Dokku on Macos:我已按照原始文档中的步骤在 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
Source: https://hub.docker.com/r/dokku/dokku资料来源: https://hub.docker.com/r/dokku/dokku
Then I've initialized the ssh-keys within the container, and made an alias for the hostname dokku.me
as advised.然后我在容器中初始化了 ssh-keys,并按照建议为主机名dokku.me
了一个别名。 Now I can connect to the Dokku container and run commands on it, like creating a new application:现在我可以连接到 Dokku 容器并在其上运行命令,例如创建一个新应用程序:
dokku apps:create node-test
dokku git:initialize node-test
I've added a new remote to my node project and tried to push:我在我的节点项目中添加了一个新的遥控器并尝试推送:
git remote add dokku dokku@dokku.me:node-test
But pushing fails with an error that I don't understand completely:但是推送失败并出现我不完全理解的错误:
➜ 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'
From Docker Desktop, I've updated the file sharing options and added /var/lib/dokku
, after I've created this folder in my Mac's filesystem.从 Docker 桌面,我更新了文件共享选项并添加了/var/lib/dokku
,在我的 Mac 文件系统中创建了这个文件夹之后。
➜ 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 ..
I suspect it has something to do with the mounted folders in the Docker host, but I cannot figure out exactly what it is.我怀疑它与 Docker 主机中安装的文件夹有关,但我无法弄清楚它到底是什么。
Macos version 12.01 macOS 版本 12.01
Dokku version独孤版
root@b6df7b8bc9b0:/tmp# dokku version
dokku version 0.26.7
Docker version: 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
I've checked again the Docker Installation Nodes for v0.26.7 and noticed the docker container run
has an extra parameter when compared to the instructions from Dockerhub :我再次检查了 v0.26.7 的Docker 安装节点,并注意到与 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
The extra param --env DOKKU_HOST_ROOT=/var/lib/dokku/home/dokku
seems to fix my issue.额外的参数--env DOKKU_HOST_ROOT=/var/lib/dokku/home/dokku
似乎解决了我的问题。
Now pushing to Dokku doesn't throw the Mounts denied
error anymore.现在推送到 Dokku 不会再抛出Mounts denied
错误了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.