ddev 启动:Web 容器失败(macOS Catalina 使用站点的文档文件夹)

ddev start: web container failed (macOS Catalina using Documents folder for site)

在终端输入 ddev start 时,出现错误

Failed to start xxx: web container failed: log=, err=container exited, please use 'ddev logs -s web` to find out why it failed 

错误日志出现

...
+ disable_xdebug
Disabled xdebug
+ ls /var/www/html
ls: cannot open directory '/var/www/html': Stale file handle
/var/www/html does not seem to be healthy/mounted; docker may not be mounting it., exiting
+ echo '/var/www/html does not seem to be healthy/mounted; docker may not be mounting it., exiting'
+ exit 101

我不知道在这里做什么。目录 /var/www 不存在,对创建它没有帮助。在网上搜索并没有带来任何有价值的信息,我唯一找到的是 this

ls /var/www/html >/dev/null || (echo "/var/www/html does not seem to be healthy/mounted; docker may not be mounting it., exiting" && exit 101)

但我不知道这是什么意思,也没有解释,该怎么做.. 这是项目相关的,我在其他项目中 docker/ddev 运行 还不错,但这个是闹鬼之类的..

我的config.yaml

APIVersion: v1.12.2
name: xxx
type: php
docroot: public
php_version: "7.2"
webserver_type: nginx-fpm
router_http_port: "80"
router_https_port: "443"
xdebug_enabled: false
additional_hostnames: []
additional_fqdns: []
mariadb_version: "10.2"
nfs_mount_enabled: true
provider: default
use_dns_when_possible: true
timezone: ""

docker-compose.yaml

web:
container_name: ddev-${DDEV_SITENAME}-web
build:
  context: '/Users/jnz/Documents/xxx/.ddev/.webimageBuild'
  args:
    BASE_IMAGE: $DDEV_WEBIMAGE
    username: 'jb'
    uid: '504'
    gid: '20'
image: ${DDEV_WEBIMAGE}-built
cap_add:
  - SYS_PTRACE
volumes:
  - type: volume
    source: nfsmount
    target: /var/www/html

    volume:
      nocopy: true

  - ".:/mnt/ddev_config:ro"
  - ddev-global-cache:/mnt/ddev-global-cache

  - ddev-ssh-agent_socket_dir:/home/.ssh-agent


restart: "no"
user: "$DDEV_UID:$DDEV_GID"
hostname: xxx-web

links:
  - db:db

# ports is list of exposed *container* ports
ports:
  - "127.0.0.1:$DDEV_HOST_WEBSERVER_PORT:80"
  - "127.0.0.1:$DDEV_HOST_HTTPS_PORT:443"
environment:
  - DOCROOT=$DDEV_DOCROOT
  - DDEV_PHP_VERSION=$DDEV_PHP_VERSION
  - DDEV_WEBSERVER_TYPE=$DDEV_WEBSERVER_TYPE
  - DDEV_PROJECT_TYPE=$DDEV_PROJECT_TYPE
  - DDEV_ROUTER_HTTP_PORT=$DDEV_ROUTER_HTTP_PORT
  - DDEV_ROUTER_HTTPS_PORT=$DDEV_ROUTER_HTTPS_PORT
  - DDEV_XDEBUG_ENABLED=$DDEV_XDEBUG_ENABLED
  - DOCKER_IP=127.0.0.1
  - HOST_DOCKER_INTERNAL_IP=
  - DEPLOY_NAME=local
  - VIRTUAL_HOST=$DDEV_HOSTNAME
  - COLUMNS=$COLUMNS
  - LINES=$LINES
  - TZ=
  # HTTP_EXPOSE allows for ports accepting HTTP traffic to be accessible from <site>.ddev.site:<port>
  # To expose a container port to a different host port, define the port as hostPort:containerPort
  - HTTP_EXPOSE=${DDEV_ROUTER_HTTP_PORT}:80,${DDEV_MAILHOG_PORT}:8025
  # You can optionally expose an HTTPS port option for any ports defined in HTTP_EXPOSE.
  # To expose an HTTPS port, define the port as securePort:containerPort.
  - HTTPS_EXPOSE=${DDEV_ROUTER_HTTPS_PORT}:80
  - SSH_AUTH_SOCK=/home/.ssh-agent/socket
  - DDEV_PROJECT=xxx
labels:
  com.ddev.site-name: ${DDEV_SITENAME}
  com.ddev.platform: ddev
  com.ddev.app-type: php
  com.ddev.approot: $DDEV_APPROOT

external_links:
- "ddev-router:xxx.ddev.site"

healthcheck:
  interval: 1s
  retries: 10
  start_period: 10s
  timeout: 120s

所以正如@rfay在评论中指出的那样,问题是由macOS catalina目录限制引起的。

我必须转到系统设置 > 安全 > 隐私 > 文件和文件夹并添加 /sbin/nfsd。它现在具有完整的高清访问权限。

此外,我授予 docker 对 documents 的访问权限。

现在 ddev 已经启动 运行,甚至在 User/xxx/Documents.

中的文件夹中